ravcredit-lib 0.0.18 → 0.0.20

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.
Files changed (51) hide show
  1. package/fesm2022/ravcredit-lib.mjs +2120 -0
  2. package/fesm2022/ravcredit-lib.mjs.map +1 -0
  3. package/index.d.ts +1789 -0
  4. package/package.json +25 -14
  5. package/ng-package.json +0 -7
  6. package/src/lib/ravcredit-lib.component.spec.ts +0 -23
  7. package/src/lib/ravcredit-lib.component.ts +0 -16
  8. package/src/lib/ravcredit-lib.service.spec.ts +0 -16
  9. package/src/lib/ravcredit-lib.service.ts +0 -9
  10. package/src/lib/v1/const/constants.ts +0 -35
  11. package/src/lib/v1/idb/idb.service.spec.ts +0 -16
  12. package/src/lib/v1/idb/indexed-db.service.ts +0 -396
  13. package/src/lib/v1/objects/oAddress.ts +0 -19
  14. package/src/lib/v1/objects/oBusiness.ts +0 -112
  15. package/src/lib/v1/objects/oClient.ts +0 -46
  16. package/src/lib/v1/objects/oConekta.ts +0 -408
  17. package/src/lib/v1/objects/oContract.ts +0 -31
  18. package/src/lib/v1/objects/oContractAll.ts +0 -38
  19. package/src/lib/v1/objects/oCustomer.ts +0 -36
  20. package/src/lib/v1/objects/oDevice.ts +0 -5
  21. package/src/lib/v1/objects/oFinancial.ts +0 -32
  22. package/src/lib/v1/objects/oGlobal.ts +0 -192
  23. package/src/lib/v1/objects/oLogIn.ts +0 -43
  24. package/src/lib/v1/objects/oNewPayment.ts +0 -18
  25. package/src/lib/v1/objects/oNotification.ts +0 -34
  26. package/src/lib/v1/objects/oPassport.ts +0 -65
  27. package/src/lib/v1/objects/oUser.ts +0 -35
  28. package/src/lib/v1/objects/oVerification.ts +0 -100
  29. package/src/lib/v1/util/UtilBusiness.ts +0 -186
  30. package/src/lib/v1/util/UtilClient.ts +0 -295
  31. package/src/lib/v1/util/UtilConekta.ts +0 -97
  32. package/src/lib/v1/util/UtilContract.ts +0 -431
  33. package/src/lib/v1/util/UtilDashboard.ts +0 -19
  34. package/src/lib/v1/util/UtilDynamiCore.ts +0 -752
  35. package/src/lib/v1/util/UtilNotification.ts +0 -46
  36. package/src/lib/v1/util/UtilPassport.ts +0 -32
  37. package/src/lib/v1/util/UtilPayment.ts +0 -22
  38. package/src/lib/v1/util/UtilTime.ts +0 -179
  39. package/src/lib/v1/util/UtilsHttp.ts +0 -25
  40. package/src/lib/v2/const/constants.ts +0 -37
  41. package/src/lib/v2/messaging/messaging.ts +0 -10
  42. package/src/lib/v2/objects/oAsset.ts +0 -49
  43. package/src/lib/v2/objects/oAws.ts +0 -8
  44. package/src/lib/v2/objects/oCatalog.ts +0 -6
  45. package/src/lib/v2/objects/oClient.ts +0 -84
  46. package/src/lib/v2/objects/oCompany.ts +0 -10
  47. package/src/lib/v2/objects/oContract.ts +0 -10
  48. package/src/public-api.ts +0 -43
  49. package/tsconfig.lib.json +0 -15
  50. package/tsconfig.lib.prod.json +0 -11
  51. package/tsconfig.spec.json +0 -15
@@ -0,0 +1,2120 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, runInInjectionContext, inject } from '@angular/core';
3
+ import { UntypedFormControl, Validators, UntypedFormArray } from '@angular/forms';
4
+ import { add, getDate, format } from 'date-fns';
5
+ import { es } from 'date-fns/locale/es';
6
+ import { openDB } from 'idb';
7
+
8
+ class RavcreditLibService {
9
+ constructor() { }
10
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RavcreditLibService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
11
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RavcreditLibService, providedIn: 'root' });
12
+ }
13
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RavcreditLibService, decorators: [{
14
+ type: Injectable,
15
+ args: [{
16
+ providedIn: 'root'
17
+ }]
18
+ }], ctorParameters: () => [] });
19
+
20
+ class RavcreditLibComponent {
21
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RavcreditLibComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
22
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: RavcreditLibComponent, isStandalone: true, selector: "lib-ravcredit-lib", ngImport: i0, template: `
23
+ <p>
24
+ ravcredit-lib works!
25
+ </p>
26
+ `, isInline: true, styles: [""] });
27
+ }
28
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RavcreditLibComponent, decorators: [{
29
+ type: Component,
30
+ args: [{ selector: 'lib-ravcredit-lib', standalone: true, imports: [], template: `
31
+ <p>
32
+ ravcredit-lib works!
33
+ </p>
34
+ ` }]
35
+ }] });
36
+
37
+ const cAddress = {
38
+ street: "",
39
+ city: "",
40
+ neighbor: "",
41
+ zip: "",
42
+ ext: "",
43
+ int: "",
44
+ state: ""
45
+ };
46
+
47
+ var eConektaRes;
48
+ (function (eConektaRes) {
49
+ eConektaRes["CUSTOMER_CREATED"] = "customer.created";
50
+ eConektaRes["ORDER_PENDING_PAYMENT"] = "order.pending_payment";
51
+ eConektaRes["ORDER_CREATED"] = "order.created";
52
+ eConektaRes["CHARGE_CREATED"] = "charge.created";
53
+ eConektaRes["ORDER_PAID"] = "order.paid";
54
+ eConektaRes["CHARGE_PAID"] = "charge.paid";
55
+ })(eConektaRes || (eConektaRes = {}));
56
+ var eConektaOrderStatus;
57
+ (function (eConektaOrderStatus) {
58
+ eConektaOrderStatus["expired"] = "expired";
59
+ eConektaOrderStatus["paid"] = "paid";
60
+ eConektaOrderStatus["pending_payment"] = "pending_payment";
61
+ })(eConektaOrderStatus || (eConektaOrderStatus = {}));
62
+ /******************************************************* New reference constant */
63
+ const cOxxorecurrentSourcesData = {
64
+ id: "",
65
+ object: "",
66
+ type: "",
67
+ provider: "",
68
+ reference: "",
69
+ barcode: "",
70
+ barcode_url: "",
71
+ expires_at: 0,
72
+ created_at: 0,
73
+ parent_id: ""
74
+ };
75
+ const cOxxoRecurrentSources = {
76
+ object: "",
77
+ has_more: false,
78
+ total: 0,
79
+ data: []
80
+ };
81
+ const cConektaRecurrent = {
82
+ livemode: false,
83
+ name: "",
84
+ email: "",
85
+ phone: "",
86
+ id: "",
87
+ object: "",
88
+ created_at: 0,
89
+ corporate: false,
90
+ custom_id: "",
91
+ payment_sources: cOxxoRecurrentSources
92
+ };
93
+ //
94
+ // {
95
+ // data: {
96
+ // object: {
97
+ // id: '66bf1b25e341ed00158a169a',
98
+ // livemode: false,
99
+ // created_at: 1723800357,
100
+ // currency: 'MXN',
101
+ // payment_method: [Object],
102
+ // object: 'charge',
103
+ // description: 'Payment from order',
104
+ // status: 'paid',
105
+ // amount: 28125,
106
+ // paid_at: 1723800396,
107
+ // fee: 1273,
108
+ // customer_id: '',
109
+ // order_id: 'ord_2wTWbvyFgywHDvTZg'
110
+ // },
111
+ // previous_attributes: { status: 'pending_payment' }
112
+ // },
113
+ // livemode: false,
114
+ // webhook_status: 'pending',
115
+ // webhook_logs: [
116
+ // {
117
+ // id: 'webhl_2wTWcRE8ThHpvG1QQ',
118
+ // url: 'https://b1b6-2806-230-2610-b3ed-dcbe-6d32-758f-17c6.ngrok-free.app/api/v1/webhook',
119
+ // failed_attempts: 0,
120
+ // last_http_response_status: -1,
121
+ // response_data: null,
122
+ // object: 'webhook_log',
123
+ // last_attempted_at: 0
124
+ // }
125
+ // ],
126
+ // id: '66bf1b4c2973ff0001dff653',
127
+ // object: 'event',
128
+ // type: 'charge.paid',
129
+ // created_at: 1723800396
130
+ // }
131
+
132
+ //
133
+ // export interface iCustomerInfo = Pick<iCustomer, email | id | name | phone> {
134
+ //
135
+ // customer_id:string
136
+ // }
137
+ // {
138
+ // livemode: false,
139
+ // name: Vicente Mendoza,
140
+ // email: vicente.mendoza@conekta.com,
141
+ // phone: 5566982093,
142
+ // id: cus_2wHtqBNsSggaYdfXu,
143
+ // object: customer,
144
+ // created_at: 1721258796,
145
+ // corporate: false,
146
+ // custom_reference:
147
+ // }
148
+
149
+ const cClient = {
150
+ id: "",
151
+ name: "",
152
+ username: "",
153
+ email: "",
154
+ phone: "",
155
+ curp: "",
156
+ contract_temporary: "",
157
+ conekta_id: "",
158
+ userReferences: [],
159
+ status: ""
160
+ };
161
+ const cUserReference = {
162
+ name: "",
163
+ phone: "",
164
+ relationship: ""
165
+ };
166
+ const cClientConekta = {
167
+ conekta: cConektaRecurrent,
168
+ ravcredit: cClient
169
+ };
170
+ const cClientContract = {
171
+ client: cClient,
172
+ contract: cContract,
173
+ };
174
+ class FactoryClient {
175
+ static CreateClientToConektaObj(data) {
176
+ const o = {};
177
+ if (data.name && data.name.length > 0)
178
+ o.name = data.name;
179
+ if (data.username && data.name.length > 0)
180
+ o.username = data.username;
181
+ if (data.email && data.email.length > 0)
182
+ o.email = data.email;
183
+ if (data.phone && data.phone.length > 0)
184
+ o.phone = String(data.phone);
185
+ if (data.curp && data.curp.length > 0)
186
+ o.curp = data.curp;
187
+ if (data.userReferences && data.userReferences.length > 0)
188
+ o.userReferences = data.userReferences;
189
+ if (data.contract)
190
+ o.contract = data.contract;
191
+ if (data.createdAt)
192
+ o.createdAt = data.createdAt;
193
+ if (data.lastLogin)
194
+ o.lastLogin = data.lastLogin;
195
+ if (data.conekta_id)
196
+ o.conekta_id = data.conekta_id;
197
+ return o;
198
+ }
199
+ static CreateClientFromFormObj(data, client) {
200
+ const o = {
201
+ id: "",
202
+ name: data["client"][0].name,
203
+ username: data["auth"][0].username,
204
+ password: data["auth"][0].password,
205
+ email: data["client"][0].email,
206
+ phone: String(data["client"][0].phone),
207
+ curp: data["client"][0].curp,
208
+ userReferences: data["client"][0].userReferences,
209
+ status: eClientStatus.ACTIVE
210
+ };
211
+ if (client != undefined) {
212
+ if (client.dynamic_id)
213
+ o.dynamic_id = client.dynamic_id;
214
+ if (client.dynamic_account)
215
+ o.dynamic_account = client.dynamic_account;
216
+ if (client.conekta_id)
217
+ o.conekta_id = client.conekta_id;
218
+ }
219
+ return o;
220
+ }
221
+ static CreateClientConektaObj(data, finalDate) {
222
+ const sources = {
223
+ type: "oxxo_recurrent",
224
+ expires_at: finalDate
225
+ };
226
+ return {
227
+ name: data.name,
228
+ email: data.email,
229
+ phone: data.phone,
230
+ contract: data.contract_temporary,
231
+ client_id: data.id,
232
+ payment_sources: [sources]
233
+ };
234
+ }
235
+ static MapperConektaClient(client, conekta) {
236
+ const o = client;
237
+ o.name = conekta.name;
238
+ o.email = conekta.email;
239
+ o.phone = conekta.phone;
240
+ o.conekta_id = conekta.id;
241
+ return {
242
+ client: o,
243
+ contract: cContract
244
+ };
245
+ }
246
+ static MapperTypeContCli_Client(_client) {
247
+ const client = {
248
+ id: _client.id,
249
+ name: _client.name,
250
+ username: _client.username,
251
+ email: _client.email,
252
+ phone: _client.phone,
253
+ curp: _client.curp,
254
+ userReferences: _client.userReferences,
255
+ status: _client.status,
256
+ contract: _client.contract,
257
+ reference: _client.reference,
258
+ references: _client.references,
259
+ conekta_id: _client.conekta_id,
260
+ dynamic_account: _client.dynamic_account,
261
+ token: _client.token,
262
+ contract_temporary: _client.contract_temporary,
263
+ lastLogin: _client.lastLogin,
264
+ dynamic_id: _client.dynamic_id,
265
+ createdAt: _client.createdAt,
266
+ payments: _client.payments,
267
+ password: _client.password,
268
+ contractUrl: _client.contractUrl,
269
+ dynamic_ref: _client.dynamic_ref,
270
+ exists: _client.exists,
271
+ passport_id: _client.passport_id,
272
+ };
273
+ return client;
274
+ }
275
+ static MapperDynamicClient(dynamic, client, contract, clientDyn, account) {
276
+ // const o: tyClientContract = cTyClientContract
277
+ /* Client ------------------------------------------------------ */
278
+ client.username = `${dynamic.pii.name} ${dynamic.pii.motherlastname} ${dynamic.pii.lastname}`;
279
+ client.phone = dynamic.pii.phone;
280
+ client.dynamic_id = dynamic.id;
281
+ client.curp = dynamic.pii.curp;
282
+ client.email = dynamic.pii.email;
283
+ if (account)
284
+ client.dynamic_account = account.id;
285
+ /* Auth ---------------------------------------------------------- */
286
+ /* Device -------------------------------------------------------- */
287
+ contract.device.IMEI = clientDyn.pii.imei;
288
+ contract.device.device = clientDyn.pii.model;
289
+ /* Contract ------------------------------------------------------ */
290
+ contract.by = clientDyn.pii.seller_name;
291
+ if (clientDyn.pii.fotografia_del_cliente_con_el_equipo != undefined) {
292
+ const oPhoto = clientDyn.pii.fotografia_del_cliente_con_el_equipo;
293
+ if (oPhoto != "") {
294
+ const _photo = JSON.parse(oPhoto);
295
+ if (_photo)
296
+ contract.photo = _photo[0].url;
297
+ }
298
+ }
299
+ contract.address.state = dynamic.pii.state;
300
+ contract.address.city = dynamic.pii.city;
301
+ contract.address.street = dynamic.pii.street;
302
+ contract.address.ext = dynamic.pii.num_ext;
303
+ contract.address.zip = dynamic.pii.zipcode;
304
+ contract.address.neighbor = dynamic.pii.colony;
305
+ /* Financial ------------------------------------------------------ */
306
+ contract.dynamicAccount = Number(account?.id);
307
+ if (account?.config.installments) {
308
+ contract.financial.deadlines = {
309
+ weeks: account.config.installments,
310
+ interest: 0
311
+ };
312
+ }
313
+ if (account?.properties.expected_disbursed)
314
+ contract.financial.total = account?.properties.expected_disbursed;
315
+ if (account?.properties.principal_disbursed)
316
+ contract.financial.financed = account?.properties.principal_disbursed;
317
+ if (account?.properties.amount_commission_opening) {
318
+ contract.financial.initial = account?.properties.amount_commission_opening;
319
+ contract.financial.amount_commission_opening = account?.properties.amount_commission_opening;
320
+ }
321
+ contract.financial.interest_rate = Number(clientDyn.pii.interest_rate);
322
+ contract.financial.interest_arrears = account?.config.interest_arrears;
323
+ contract.financial.commission_opening = account?.config.commission_opening;
324
+ contract.financial.credit_type = account?.config.credit_type;
325
+ contract.financial.principal_disbursed = account?.properties.principal_disbursed;
326
+ contract.financial.expected_disbursed = account?.properties.expected_disbursed;
327
+ contract.financial.weeklyPayment = Number(clientDyn.pii.amount_by_period);
328
+ return {
329
+ client: client,
330
+ contract: contract,
331
+ };
332
+ }
333
+ static MapperFinancialContract(contract, account) {
334
+ contract.dynamicAccount = Number(account.id);
335
+ if (account.config.installments) {
336
+ contract.financial.deadlines = {
337
+ weeks: account.config.installments,
338
+ interest: 0
339
+ };
340
+ }
341
+ const total = account.config.financed_amount != undefined ? account.config.financed_amount : 0;
342
+ if (total > 0)
343
+ contract.financial.total = total;
344
+ // if (account.properties.expected_disbursed)
345
+ const expected_disbursed = account.properties.expected_disbursed != undefined ? account.properties.expected_disbursed : 0;
346
+ if (expected_disbursed > 0)
347
+ contract.financial.total = expected_disbursed;
348
+ contract.financial.expected_disbursed = expected_disbursed;
349
+ contract.financial.interest_rate = account.config.interest_rate;
350
+ contract.financial.interest_arrears = account.config.interest_arrears;
351
+ // if (account.properties.principal_disbursed)
352
+ if (account.properties.principal_disbursed > 0)
353
+ contract.financial.financed = account.properties.principal_disbursed;
354
+ contract.financial.principal_disbursed = account.properties.principal_disbursed;
355
+ const amount_commission_opening = account.properties.amount_commission_opening != undefined ? account.properties.amount_commission_opening : 0;
356
+ if (amount_commission_opening > 0)
357
+ contract.financial.initial = amount_commission_opening;
358
+ contract.financial.amount_commission_opening = amount_commission_opening;
359
+ contract.financial.interest_arrears = account.config.interest_arrears;
360
+ contract.financial.commission_opening = account.config.commission_opening;
361
+ contract.financial.credit_type = account.config.credit_type;
362
+ contract.financial.clabe = String(account.properties.clabe);
363
+ return contract.financial;
364
+ }
365
+ }
366
+ var eIdentityTypes;
367
+ (function (eIdentityTypes) {
368
+ eIdentityTypes["SELFIE"] = "SELFIE";
369
+ eIdentityTypes["IDENTITY_FRONT"] = "IDENTITY_FRONT";
370
+ eIdentityTypes["IDENTITY_BACK"] = "IDENTITY_BACK";
371
+ eIdentityTypes["PASSPORT_FRONT"] = "PASSPORT_FRONT";
372
+ eIdentityTypes["PASSPORT_BACK"] = "PASSPORT_BACK";
373
+ eIdentityTypes["SERVICE"] = "SERVICE";
374
+ eIdentityTypes["WITH_DEVICE"] = "WITH_DEVICE";
375
+ })(eIdentityTypes || (eIdentityTypes = {}));
376
+
377
+ const cSchedule = {
378
+ day: "",
379
+ open: 0,
380
+ close: 0,
381
+ };
382
+ const cEmptyDay = {
383
+ close: 0, open: 0, day: ""
384
+ };
385
+ const week = [
386
+ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
387
+ ];
388
+ const cDefinedSchedule = [
389
+ { close: 0, open: 0, day: "monday" },
390
+ { close: 0, open: 0, day: "tuesday" },
391
+ { close: 0, open: 0, day: "wednesday" },
392
+ { close: 0, open: 0, day: "thursday" },
393
+ { close: 0, open: 0, day: "friday" },
394
+ { close: 0, open: 0, day: "saturday" },
395
+ { close: 0, open: 0, day: "sunday" },
396
+ ];
397
+ const cBusinessInfo = {
398
+ version: "v2024",
399
+ name: "",
400
+ address: cAddress,
401
+ phones: [],
402
+ email: "",
403
+ };
404
+ const cBusinessDeadlines = {
405
+ weeks: 0,
406
+ interest: 0
407
+ };
408
+ const cBusinessConfig = {
409
+ version: "",
410
+ apiVersion: "",
411
+ adminVersion: "",
412
+ mobileVersion: "",
413
+ mobileVersionPrev: "",
414
+ deadlines: [],
415
+ downloadsClient: false,
416
+ passportPaymentReference: false,
417
+ conektaPaymentReference: false,
418
+ conektaPaymentLink: false,
419
+ dynamicPaymentReference: false,
420
+ apkUrl: "https://firebasestorage.googleapis.com/v0/b/ravcredit-2b079.appspot.com/o/mobile-app%2Fapp-release.apk?alt=media&token=ae05f332-a39a-46ad-8a64-312ae1487496"
421
+ };
422
+ class FactoryBusiness {
423
+ static FormBusinessInfo(info) {
424
+ let data = cBusinessInfo;
425
+ if (info)
426
+ data = info;
427
+ if (!info?.address)
428
+ data.address = cAddress;
429
+ return {
430
+ name: new UntypedFormControl(data.name, Validators.required),
431
+ email: new UntypedFormControl(data.email, [Validators.required, Validators.email]),
432
+ desc: new UntypedFormControl(data.desc, [Validators.required, Validators.email]),
433
+ street: new UntypedFormControl(data.address.street, Validators.required),
434
+ neighbor: new UntypedFormControl(data.address.neighbor, Validators.required),
435
+ cp: new UntypedFormControl(data.address.zip, Validators.required),
436
+ ext: new UntypedFormControl(data.address.ext, Validators.required),
437
+ int: new UntypedFormControl(data.address.int),
438
+ city: new UntypedFormControl(data.address.city, Validators.required),
439
+ state: new UntypedFormControl(data.address.state, Validators.required),
440
+ phones: new UntypedFormControl(data.phones),
441
+ mondayOpen: new UntypedFormControl(data.schedule?.monday.open),
442
+ mondayClose: new UntypedFormControl(data.schedule?.monday.close),
443
+ tuesdayOpen: new UntypedFormControl(data.schedule?.tuesday.open),
444
+ tuesdayClose: new UntypedFormControl(data.schedule?.tuesday.close),
445
+ wednesdayOpen: new UntypedFormControl(data.schedule?.wednesday.open),
446
+ wednesdayClose: new UntypedFormControl(data.schedule?.wednesday.close),
447
+ thursdayOpen: new UntypedFormControl(data.schedule?.thursday.open),
448
+ thursdayClose: new UntypedFormControl(data.schedule?.thursday.close),
449
+ fridayOpen: new UntypedFormControl(data.schedule?.friday.open),
450
+ fridayClose: new UntypedFormControl(data.schedule?.friday.close),
451
+ saturdayOpen: new UntypedFormControl(data.schedule?.saturday.open),
452
+ saturdayClose: new UntypedFormControl(data.schedule?.saturday.close),
453
+ sundayOpen: new UntypedFormControl(data.schedule?.sunday.open),
454
+ sundayClose: new UntypedFormControl(data.schedule?.sunday.close),
455
+ };
456
+ }
457
+ static CreateBusinessInfoObj(data) {
458
+ const address = cAddress;
459
+ const schedule = {
460
+ monday: {},
461
+ tuesday: {},
462
+ wednesday: {},
463
+ thursday: {},
464
+ friday: {},
465
+ saturday: {},
466
+ sunday: {}
467
+ };
468
+ if (data.street)
469
+ address.street = data.street;
470
+ if (data.state)
471
+ address.state = data.state;
472
+ if (data.neighbor)
473
+ address.neighbor = data.neighbor;
474
+ if (data.city)
475
+ address.city = data.city;
476
+ if (data.ext)
477
+ address.ext = data.ext;
478
+ if (data.int)
479
+ address.int = data.int;
480
+ if (data.cp)
481
+ address.zip = data.cp;
482
+ if (data.mondayOpen)
483
+ schedule.monday.open = data.mondayOpen;
484
+ if (data.mondayClose)
485
+ schedule.monday.close = data.mondayClose;
486
+ if (data.tuesdayOpen)
487
+ schedule.tuesday.open = data.tuesdayOpen;
488
+ if (data.tuesdayClose)
489
+ schedule.tuesday.close = data.tuesdayClose;
490
+ if (data.wednesdayOpen)
491
+ schedule.wednesday.open = data.wednesdayOpen;
492
+ if (data.wednesdayClose)
493
+ schedule.wednesday.close = data.wednesdayClose;
494
+ if (data.thursdayOpen)
495
+ schedule.thursday.open = data.thursdayOpen;
496
+ if (data.thursdayClose)
497
+ schedule.thursday.close = data.thursdayClose;
498
+ if (data.fridayOpen)
499
+ schedule.friday.open = data.fridayOpen;
500
+ if (data.fridayClose)
501
+ schedule.friday.close = data.fridayClose;
502
+ if (data.saturdayOpen)
503
+ schedule.saturday.open = data.saturdayOpen;
504
+ if (data.saturdayClose)
505
+ schedule.saturday.close = data.saturdayClose;
506
+ if (data.sundayOpen)
507
+ schedule.sunday.open = data.sundayOpen;
508
+ if (data.sundayClose)
509
+ schedule.sunday.close = data.sundayClose;
510
+ const info = {
511
+ version: "v2024",
512
+ name: data.name ? data.name : "",
513
+ address: address,
514
+ phones: data.phones ? data.phones : [],
515
+ email: data.email ? data.email : "",
516
+ schedule: schedule,
517
+ desc: data.desc ? data.desc : ""
518
+ };
519
+ return info;
520
+ }
521
+ static FormDeadlineConfig(data) {
522
+ // if (!data) data = cBusinessDeadlines
523
+ return {
524
+ weeks: new UntypedFormControl(data.weeks),
525
+ interest: new UntypedFormControl(data.interest),
526
+ };
527
+ }
528
+ static FormBusinessConfig(config) {
529
+ let data = cBusinessConfig;
530
+ if (config)
531
+ data = config;
532
+ return {
533
+ downloadsClient: new UntypedFormControl(data.downloadsClient),
534
+ passportPaymentReference: new UntypedFormControl(data.passportPaymentReference),
535
+ conektaPaymentReference: new UntypedFormControl(data.conektaPaymentReference),
536
+ conektaPaymentLink: new UntypedFormControl(data.conektaPaymentLink),
537
+ dynamicPaymentReference: new UntypedFormControl(data.dynamicPaymentReference),
538
+ deadlines: new UntypedFormArray([])
539
+ };
540
+ }
541
+ static testBusiness(message) {
542
+ return `Message ${message}`;
543
+ }
544
+ }
545
+
546
+ // import {oScore, oScoreReference} from '../../v2/objects/oClient';
547
+ var eProvider;
548
+ (function (eProvider) {
549
+ eProvider["none"] = "";
550
+ eProvider["Conekta"] = "Conekta";
551
+ eProvider["Passport"] = "Passport";
552
+ eProvider["DynamiCore"] = "DynamiCore";
553
+ })(eProvider || (eProvider = {}));
554
+ // export type ProgressTaskStatus = TaskState | "uploading" | "idle" | "generating" | "unauthorized"
555
+ const cDevice = {
556
+ device: "",
557
+ IMEI: ""
558
+ };
559
+ const cFinancial = {
560
+ total: 0,
561
+ initial: 0,
562
+ deadlines: cBusinessDeadlines,
563
+ initDate: 0,
564
+ weeklyPayment: 0,
565
+ pendingOf: [],
566
+ progress: [],
567
+ interest: 0,
568
+ provider: eProvider.DynamiCore,
569
+ financed: 0,
570
+ nextPayment: 0,
571
+ amount_commission_opening: 0,
572
+ principal_disbursed: 0,
573
+ expected_disbursed: 0, // ---------
574
+ credit_type: 'Arrendamiento',
575
+ interest_rate: 0,
576
+ commission_opening: 0,
577
+ interest_arrears: 0,
578
+ };
579
+ const cContract = {
580
+ id: "",
581
+ client: "",
582
+ address: cAddress,
583
+ device: cDevice,
584
+ financial: cFinancial,
585
+ by: "",
586
+ active: true
587
+ };
588
+ class FactoryContract {
589
+ static FormClient(client) {
590
+ let data = cClient;
591
+ if (client)
592
+ data = client;
593
+ return {
594
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
595
+ email: new UntypedFormControl(data.username, [Validators.required, Validators.email]),
596
+ phone: new UntypedFormControl(data.phone, [Validators.required, Validators.min(10)]),
597
+ curp: new UntypedFormControl(data.curp, [Validators.required, Validators.minLength(16)]),
598
+ userReferences: new UntypedFormArray([])
599
+ };
600
+ }
601
+ static CreateUserReferenceFormObj(user) {
602
+ let data = cUserReference;
603
+ if (user.name != "")
604
+ data = user;
605
+ return {
606
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
607
+ phone: new UntypedFormControl(data.phone, [Validators.required]),
608
+ relationship: new UntypedFormControl(data.relationship, [Validators.required]),
609
+ };
610
+ }
611
+ static FormAddress(address) {
612
+ let data = cAddress;
613
+ if (address)
614
+ data = address;
615
+ return {
616
+ street: new UntypedFormControl(data.street, Validators.required),
617
+ neighbor: new UntypedFormControl(data.neighbor, Validators.required),
618
+ cp: new UntypedFormControl(data.zip, Validators.required),
619
+ ext: new UntypedFormControl(data.ext, Validators.required),
620
+ int: new UntypedFormControl(data.int),
621
+ city: new UntypedFormControl(data.city, Validators.required),
622
+ state: new UntypedFormControl(data.state, Validators.required),
623
+ };
624
+ }
625
+ static FormDevice(device) {
626
+ let data = cDevice;
627
+ if (device)
628
+ data = device;
629
+ return {
630
+ model: new UntypedFormControl(data.device, Validators.required),
631
+ IMEI: new UntypedFormControl(data.IMEI, Validators.required),
632
+ ID: new UntypedFormControl(data.id),
633
+ };
634
+ }
635
+ static FormFinancial(financial) {
636
+ let data = cFinancial;
637
+ if (financial)
638
+ data = financial;
639
+ data.credit_type = "Arrendamiento";
640
+ // data.deadlines.weeks = cBusinessDeadlines
641
+ return {
642
+ total: new UntypedFormControl(data.total, [Validators.required, Validators.min(1)]),
643
+ initial: new UntypedFormControl(data.initial, [Validators.required]),
644
+ financed: new UntypedFormControl(data.financed, Validators.min(1)),
645
+ weeklyPayment: new UntypedFormControl(data.weeklyPayment, [Validators.required, Validators.min(1)]),
646
+ deadlines: new UntypedFormControl(data.deadlines, [Validators.required]),
647
+ initDate: new UntypedFormControl(data.initDate),
648
+ provider: new UntypedFormControl(data.provider),
649
+ credit_type: new UntypedFormControl(data.credit_type ? data.credit_type : 0),
650
+ interest_rate: new UntypedFormControl(data.interest_rate ? data.interest_rate : 0), // interes credit dynamic
651
+ commission_opening: new UntypedFormControl(data.commission_opening ? data.commission_opening : 0),
652
+ interest_arrears: new UntypedFormControl(data.interest_arrears ? data.interest_arrears : 0), // intereses moratorios dynamic
653
+ amount_commission_opening: new UntypedFormControl(data.amount_commission_opening), // comision por apertura dynamic
654
+ principal_disbursed: new UntypedFormControl(data.principal_disbursed),
655
+ expected_disbursed: new UntypedFormControl(data.expected_disbursed)
656
+ };
657
+ }
658
+ static CreateContractFromFormObj(data, finalPay) {
659
+ const date = new Date();
660
+ const device = {
661
+ device: data["device"][0].model,
662
+ id: data["device"][0].ID,
663
+ IMEI: data["device"][0].IMEI
664
+ };
665
+ const address = {
666
+ street: data["address"][0].street,
667
+ city: data["address"][0].city,
668
+ neighbor: data["address"][0].neighbor,
669
+ zip: data["address"][0].cp,
670
+ ext: data["address"][0].ext,
671
+ int: data["address"][0].int,
672
+ state: data["address"][0].state
673
+ };
674
+ const financial = {
675
+ total: Number(data["financial"][0].total),
676
+ initial: data["financial"][0].initial,
677
+ deadlines: data["financial"][0].deadlines,
678
+ progress: [],
679
+ pendingOf: [],
680
+ weeklyPayment: data["financial"][0].weeklyPayment,
681
+ interest: data["financial"][0].interest_rate,
682
+ finalDate: date.getTime() + (data["financial"][0].deadlines.weeks * (604800 * 1000)),
683
+ initDate: date.getDate(),
684
+ dayCut: date.getDate(),
685
+ provider: data["financial"][0].provider,
686
+ finalPayment: finalPay,
687
+ financed: data["financial"][0].financed,
688
+ nextPayment: data["financial"][0].nextPayment
689
+ };
690
+ if (data["financial"][0].provider == eProvider.DynamiCore) {
691
+ financial.initial = data["financial"][0].amount_commission_opening ? Number(data["financial"][0].amount_commission_opening) : 0;
692
+ financial.expected_disbursed = data["financial"][0].expected_disbursed ? Number(data["financial"][0].expected_disbursed) : 0;
693
+ financial.principal_disbursed = data["financial"][0].principal_disbursed ? Number(data["financial"][0].principal_disbursed) : 0;
694
+ financial.interest_arrears = data["financial"][0].interest_rate ? Number(data["financial"][0].interest_rate) : 0;
695
+ financial.commission_opening = data["financial"][0].commission_opening ? Number(data["financial"][0].commission_opening) : 0;
696
+ financial.credit_type = data["financial"][0].credit_type ? data["financial"][0].credit_type : "";
697
+ financial.clabe = data["financial"][0].clabe ? data["financial"][0].clabe : "";
698
+ }
699
+ if (data["financial"][0].amount_commission_opening != undefined) {
700
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
701
+ financial.initial = Number(data["financial"][0].amount_commission_opening);
702
+ else
703
+ financial.initial = Number(data["financial"][0].initial);
704
+ }
705
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
706
+ financial.amount_commission_opening = Number(data["financial"][0].amount_commission_opening);
707
+ else
708
+ financial.amount_commission_opening = financial.initial;
709
+ if (financial.nextPayment == undefined)
710
+ financial.nextPayment = 0;
711
+ const contract = {
712
+ id: "",
713
+ client: "",
714
+ address: address,
715
+ device: device,
716
+ financial: financial,
717
+ by: "",
718
+ active: true,
719
+ lastPayment: date.getTime(),
720
+ createdAt: date.getTime()
721
+ };
722
+ return contract;
723
+ }
724
+ static CreateContractToConektaObj(data, monthlyPay, finalPay) {
725
+ const o = {};
726
+ const score = {
727
+ name: "",
728
+ score: 0
729
+ };
730
+ const catalog = {
731
+ name: "",
732
+ description: "",
733
+ id: "",
734
+ createdAt: 0
735
+ };
736
+ const brand = {
737
+ name: "",
738
+ id: "",
739
+ description: ""
740
+ };
741
+ const category = {
742
+ name: "",
743
+ id: "",
744
+ createAt: 0
745
+ };
746
+ const deviceV2 = {
747
+ name: "",
748
+ id: "",
749
+ createAt: new Date().getTime(),
750
+ category: category,
751
+ brand: brand,
752
+ price: 0,
753
+ model: "",
754
+ imageUrl: [],
755
+ paymentOption: [],
756
+ catalog: catalog,
757
+ offers: [],
758
+ score: score,
759
+ IMEI: ""
760
+ };
761
+ const device = {
762
+ device: data.device.device,
763
+ id: data.device.id,
764
+ IMEI: data.device.IMEI
765
+ };
766
+ const address = {
767
+ street: data.address.street,
768
+ city: data.address.city,
769
+ neighbor: data.address.neighbor,
770
+ zip: data.address.zip,
771
+ ext: data.address.ext,
772
+ int: data.address.int,
773
+ state: data.address.state
774
+ };
775
+ const financial = {
776
+ total: data.financial.total,
777
+ initial: data.financial.initial,
778
+ deadlines: data.financial.deadlines,
779
+ progress: data.financial.progress,
780
+ pendingOf: data.financial.pendingOf,
781
+ weeklyPayment: data.financial.weeklyPayment,
782
+ interest: data.financial.interest,
783
+ finalDate: data.financial.finalDate,
784
+ initDate: data.financial.initDate,
785
+ dayCut: data.financial.dayCut,
786
+ provider: data.financial.provider,
787
+ finalPayment: data.financial.finalPayment,
788
+ financed: data.financial.financed,
789
+ nextPayment: data.financial.nextPayment
790
+ };
791
+ const contract = {
792
+ id: "",
793
+ client: "",
794
+ address: address,
795
+ device: device,
796
+ financial: financial,
797
+ by: "",
798
+ active: true
799
+ };
800
+ return contract;
801
+ }
802
+ static CreateAuthForm(username, curp) {
803
+ const password = this.createPassword(curp);
804
+ return {
805
+ username: new UntypedFormControl(username, Validators.required),
806
+ password: new UntypedFormControl(password, Validators.required),
807
+ };
808
+ }
809
+ static createPassword(curp) {
810
+ const _curp = curp.split("");
811
+ let password = "";
812
+ const limit = 7;
813
+ if (_curp.length < 16)
814
+ return "";
815
+ password += _curp[0].toLowerCase();
816
+ for (let i = 1; i <= limit; i++)
817
+ password += _curp[i].toUpperCase();
818
+ password += `*`;
819
+ return password;
820
+ }
821
+ static MapperTypeContCli_Contract(_contract) {
822
+ const contract = {
823
+ id: _contract.contract,
824
+ client: _contract.client,
825
+ address: _contract.address,
826
+ device: _contract.device,
827
+ financial: _contract.financial,
828
+ by: _contract.by,
829
+ active: _contract.active,
830
+ lastPayment: _contract.lastPayment,
831
+ createdAt: _contract.createdAt,
832
+ dynamicAccount: _contract.dynamicAccount,
833
+ };
834
+ return contract;
835
+ }
836
+ static MapperSyncContractDynamic(base, account) {
837
+ let nContract = base;
838
+ let _financial = base.financial;
839
+ let _device = base.device;
840
+ const financial = {
841
+ total: _financial.total,
842
+ initial: account.properties.amount_commission_opening ? account.properties.amount_commission_opening : _financial.initial,
843
+ deadlines: _financial.deadlines,
844
+ progress: _financial.progress ? _financial.progress : [],
845
+ pendingOf: _financial.pendingOf ? _financial.pendingOf : [],
846
+ weeklyPayment: _financial.weeklyPayment,
847
+ interest: _financial.interest,
848
+ finalDate: _financial.finalDate,
849
+ initDate: _financial.initDate,
850
+ dayCut: _financial.dayCut,
851
+ provider: _financial.provider,
852
+ finalPayment: _financial.finalPayment,
853
+ financed: _financial.financed,
854
+ nextPayment: _financial.nextPayment ? _financial.nextPayment : 0,
855
+ amount_commission_opening: account.properties.amount_commission_opening,
856
+ expected_disbursed: account.properties.expected_disbursed ?
857
+ Number(account.properties.expected_disbursed) :
858
+ Number(_financial.expected_disbursed),
859
+ principal_disbursed: account.properties.principal_disbursed ?
860
+ account.properties.principal_disbursed :
861
+ _financial.principal_disbursed,
862
+ commission_opening: account.config.commission_opening ?
863
+ Number(account.config.commission_opening) :
864
+ Number(_financial.commission_opening),
865
+ credit_type: account.config.credit_type ? account.config.credit_type : _financial.credit_type,
866
+ clabe: String(account.properties.clabe ? account.properties.clabe : _financial.clabe)
867
+ };
868
+ const interestArrears = account.config.interest_arrears;
869
+ const prevInterestArrears = _financial.interest_arrears;
870
+ if (interestArrears != undefined) {
871
+ financial.interest_arrears = interestArrears;
872
+ }
873
+ else if (prevInterestArrears != undefined) {
874
+ financial.interest_arrears = prevInterestArrears;
875
+ }
876
+ else {
877
+ financial.interest_arrears = 0;
878
+ }
879
+ const interest = account.config.interest_rate;
880
+ const prevInterest = _financial.interest;
881
+ if (interest != undefined) {
882
+ financial.interest = interest;
883
+ }
884
+ else if (prevInterest != undefined) {
885
+ financial.interest = prevInterest;
886
+ }
887
+ else {
888
+ financial.interest = 0;
889
+ }
890
+ if (account.properties.amount_commission_opening != undefined) {
891
+ if (Number(account.properties.amount_commission_opening) > 0) {
892
+ financial.initial = Number(account.properties.amount_commission_opening);
893
+ financial.amount_commission_opening = Number(account.properties.amount_commission_opening);
894
+ }
895
+ else {
896
+ financial.initial = Number(_financial.initial);
897
+ financial.amount_commission_opening = financial.initial;
898
+ }
899
+ }
900
+ const seller = account.properties.seller_name;
901
+ nContract.by = seller != null ? seller : "";
902
+ nContract.device.id = _device.id ? _device.id : "";
903
+ nContract.financial = financial;
904
+ return nContract;
905
+ }
906
+ }
907
+ var eContractStatus;
908
+ (function (eContractStatus) {
909
+ eContractStatus["APPROVED"] = "APPROVED";
910
+ eContractStatus["DENIED"] = "DENIED";
911
+ eContractStatus["CANCELED"] = "CANCELED";
912
+ eContractStatus["PENDING"] = "PENDING";
913
+ eContractStatus["CHECKING"] = "CHECKING";
914
+ })(eContractStatus || (eContractStatus = {}));
915
+
916
+ var eRoles;
917
+ (function (eRoles) {
918
+ eRoles["Administrator"] = "Administrator";
919
+ eRoles["Seller"] = "Seller";
920
+ eRoles["Consultant"] = "Consultant";
921
+ })(eRoles || (eRoles = {}));
922
+ var eProcessStatus;
923
+ (function (eProcessStatus) {
924
+ eProcessStatus["IDLE"] = "IDLE";
925
+ eProcessStatus["ERROR"] = "ERROR";
926
+ eProcessStatus["CANCELED"] = "CANCELED";
927
+ eProcessStatus["COMPLETE"] = "COMPLETE";
928
+ eProcessStatus["PROCESSING"] = "PROCESSING";
929
+ eProcessStatus["WAITING"] = "WAITING";
930
+ })(eProcessStatus || (eProcessStatus = {}));
931
+ var eLoginStatus;
932
+ (function (eLoginStatus) {
933
+ eLoginStatus["IDLE"] = "IDLE";
934
+ eLoginStatus["ERROR"] = "ERROR";
935
+ eLoginStatus["AUTHORIZED"] = "AUTHORIZED";
936
+ eLoginStatus["CHECKING"] = "CHECKING";
937
+ eLoginStatus["NOAUTHORIZED"] = "NOAUTHORIZED";
938
+ eLoginStatus["NOTFOUND"] = "NOTFOUND";
939
+ eLoginStatus["ERRORPASSWORD"] = "ERRORPASSWORD";
940
+ })(eLoginStatus || (eLoginStatus = {}));
941
+ var eClientStatus;
942
+ (function (eClientStatus) {
943
+ eClientStatus["ACTIVE"] = "active";
944
+ eClientStatus["COMPLETED"] = "completed";
945
+ eClientStatus["PAUSED"] = "paused";
946
+ eClientStatus["CANCELED"] = "canceled";
947
+ eClientStatus["LATE"] = "late";
948
+ })(eClientStatus || (eClientStatus = {}));
949
+ const cSingleOptionClientStatus = {
950
+ viewValue: "",
951
+ value: ""
952
+ };
953
+ const cOptionsClientStatus = [
954
+ {
955
+ value: eClientStatus.ACTIVE,
956
+ viewValue: "Activar"
957
+ }, {
958
+ value: eClientStatus.COMPLETED,
959
+ viewValue: "Completar"
960
+ }, {
961
+ value: eClientStatus.PAUSED,
962
+ viewValue: "Pausar"
963
+ }, {
964
+ value: eClientStatus.LATE,
965
+ viewValue: "Marcar con atraso"
966
+ }, {
967
+ value: eClientStatus.CANCELED,
968
+ viewValue: "Cancelar"
969
+ }
970
+ ];
971
+ const eRolesSelect = [
972
+ {
973
+ value: eRoles.Administrator,
974
+ viewValue: eRoles.Administrator
975
+ },
976
+ {
977
+ value: eRoles.Consultant,
978
+ viewValue: eRoles.Consultant
979
+ },
980
+ {
981
+ value: eRoles.Seller,
982
+ viewValue: eRoles.Seller
983
+ },
984
+ ];
985
+ const cPaymentDalay = {
986
+ today: 0,
987
+ nextPayment: 0,
988
+ daysDelay: 0,
989
+ late: false,
990
+ };
991
+ const snackBarConfigAction = {
992
+ horizontalPosition: "start"
993
+ };
994
+ const snackBarConfigNoAction = {
995
+ duration: 4000,
996
+ horizontalPosition: "start"
997
+ };
998
+ const snackBarConfigNoActionLong = {
999
+ duration: 8000,
1000
+ horizontalPosition: "start"
1001
+ };
1002
+ const cTyClientContract = { ...cClient, ...cContract };
1003
+
1004
+ var eAuthActions;
1005
+ (function (eAuthActions) {
1006
+ eAuthActions["delete"] = "delete";
1007
+ eAuthActions["auth"] = "auth";
1008
+ })(eAuthActions || (eAuthActions = {}));
1009
+ var eAuthType;
1010
+ (function (eAuthType) {
1011
+ eAuthType["auth"] = "auth";
1012
+ eAuthType["login"] = "login";
1013
+ eAuthType["idle"] = "";
1014
+ })(eAuthType || (eAuthType = {}));
1015
+ const cAuthConfig = {
1016
+ title: "",
1017
+ desc: "",
1018
+ data: true,
1019
+ };
1020
+
1021
+ const cTopic = "RavCreditClients";
1022
+ var eNotificationType;
1023
+ (function (eNotificationType) {
1024
+ eNotificationType["GLOBAL"] = "global";
1025
+ eNotificationType["USER"] = "user";
1026
+ eNotificationType["PAYMENT"] = "payment";
1027
+ })(eNotificationType || (eNotificationType = {}));
1028
+ const cNotification = {
1029
+ notification: {
1030
+ title: "",
1031
+ body: ""
1032
+ },
1033
+ data: {
1034
+ route: ""
1035
+ }
1036
+ };
1037
+
1038
+ var ePassportTypes;
1039
+ (function (ePassportTypes) {
1040
+ ePassportTypes["CREATE"] = "create_references";
1041
+ ePassportTypes["SEND"] = "send_references";
1042
+ })(ePassportTypes || (ePassportTypes = {}));
1043
+ /** ******************************** */
1044
+
1045
+ // export enum oGenVerificationProvider {
1046
+ // pending, approved, expired
1047
+ // }
1048
+ //
1049
+ // export interface oVerificationLookup {
1050
+ // carrier: any[]
1051
+ // }
1052
+ //
1053
+ // export interface oVerificationSenCodeAttempt {
1054
+ // attempt_sid: any[],
1055
+ // channel: any[],
1056
+ // time: any[]
1057
+ // }
1058
+ //
1059
+ // export interface oGenVerification {
1060
+ // Sid: string
1061
+ // ServiceSid: string,
1062
+ // AccountSid: string,
1063
+ // To: string,
1064
+ // Channel: any,
1065
+ // Status: oGenVerificationProvider,
1066
+ // Valid: boolean,
1067
+ // Lookup: oVerificationLookup,
1068
+ // SendCodeAttempts: oVerificationSenCodeAttempt[],
1069
+ // DateCreated: string,
1070
+ // DateUpdated: string,
1071
+ // Url: string
1072
+ // }
1073
+ //
1074
+ // export interface oVerification {
1075
+ // Sid : string,
1076
+ // ServiceSid : string,
1077
+ // AccountSid : string,
1078
+ // To : string,
1079
+ // Channel : any,
1080
+ // Status : oGenVerificationProvider,
1081
+ // Valid : boolean,
1082
+ // DateCreated : string,
1083
+ // DateUpdated : string
1084
+ // }
1085
+ var eVerificationStep;
1086
+ (function (eVerificationStep) {
1087
+ eVerificationStep["IDLE"] = "IDLE";
1088
+ eVerificationStep["ERROR"] = "ERROR";
1089
+ eVerificationStep["COMPLETED"] = "COMPLETED";
1090
+ eVerificationStep["IN_PROGRESS"] = "IN_PROGRESS";
1091
+ eVerificationStep["INVALID"] = "INVALID";
1092
+ eVerificationStep["SUSPENDED"] = "SUSPENDED";
1093
+ eVerificationStep["CANCELLED"] = "CANCELLED";
1094
+ })(eVerificationStep || (eVerificationStep = {}));
1095
+ var eVerificationStatus;
1096
+ (function (eVerificationStatus) {
1097
+ eVerificationStatus["APPROVED"] = "approved";
1098
+ eVerificationStatus["CANCELLED"] = "cancelled";
1099
+ })(eVerificationStatus || (eVerificationStatus = {}));
1100
+ var eVerificationChannel;
1101
+ (function (eVerificationChannel) {
1102
+ eVerificationChannel["SMS"] = "sms";
1103
+ eVerificationChannel["WHATSAPP"] = "whatsapp";
1104
+ eVerificationChannel["CALL"] = "call";
1105
+ eVerificationChannel["EMAIL"] = "email";
1106
+ eVerificationChannel["SNA"] = "sna";
1107
+ })(eVerificationChannel || (eVerificationChannel = {}));
1108
+
1109
+ class UtilsHttp {
1110
+ static CreateHeadersRavcreditApi(token) {
1111
+ return {
1112
+ 'Content-Type': 'application/json',
1113
+ 'Accept': 'application/json',
1114
+ 'Access-Control-Allow-Headers': 'Content-Type',
1115
+ 'Authorization': `Bearer ${token}`
1116
+ };
1117
+ }
1118
+ static CreateSimpleHeadersApi() {
1119
+ return {
1120
+ 'Content-Type': 'application/json',
1121
+ 'Accept': 'application/json',
1122
+ 'Access-Control-Allow-Headers': 'Content-Type',
1123
+ };
1124
+ }
1125
+ static CreateAwsHeadersApi() {
1126
+ return {
1127
+ 'Content-Type': 'application/json'
1128
+ };
1129
+ }
1130
+ }
1131
+
1132
+ var eReferenceStatusRav;
1133
+ (function (eReferenceStatusRav) {
1134
+ eReferenceStatusRav["Disponible"] = "Disponible";
1135
+ eReferenceStatusRav["Active"] = "Activo con credito vigente";
1136
+ eReferenceStatusRav["ActiveEnded"] = "Activo sin credito vigente";
1137
+ eReferenceStatusRav["Registered"] = "Registrado";
1138
+ eReferenceStatusRav["NonRegistered"] = "No registrado";
1139
+ eReferenceStatusRav["NonVerified"] = "No verificado";
1140
+ eReferenceStatusRav["Rejected"] = "Rechazado";
1141
+ eReferenceStatusRav["Pending"] = "Pendiente";
1142
+ })(eReferenceStatusRav || (eReferenceStatusRav = {}));
1143
+ var eAccountDynamicStatus;
1144
+ (function (eAccountDynamicStatus) {
1145
+ eAccountDynamicStatus["OK"] = "Con cuenta activa";
1146
+ eAccountDynamicStatus["NOK"] = "Sin cuenta activa";
1147
+ })(eAccountDynamicStatus || (eAccountDynamicStatus = {}));
1148
+ //
1149
+ // export enum eAccountDynamicRegister {
1150
+ // "Active" = "Activo", // Ok
1151
+ // "NonAuthorized" = "No autorizado",
1152
+ // "Authorized" = "Autorizado", // Non ref
1153
+ // "Accepted" = "Aceptado", // Non ref
1154
+ // "Rejected" = "Rechazado", // Non ref
1155
+ // "Pending" = "Pendiente", // Non ref
1156
+ // "NotFound" = "No registrado"
1157
+ // }
1158
+ var eClientDynamicStatus;
1159
+ (function (eClientDynamicStatus) {
1160
+ eClientDynamicStatus["Active"] = "Active";
1161
+ eClientDynamicStatus["Pending"] = "Pending";
1162
+ eClientDynamicStatus["Accepted"] = "Accepted";
1163
+ eClientDynamicStatus["Rejected"] = "Rejected";
1164
+ eClientDynamicStatus["approved"] = "Aprobado";
1165
+ })(eClientDynamicStatus || (eClientDynamicStatus = {}));
1166
+ const cClientDynamicStatus = {
1167
+ Active: {
1168
+ value: "Active",
1169
+ viewValue: "Activo"
1170
+ },
1171
+ Pending: {
1172
+ value: "Pending",
1173
+ viewValue: "Pendiente"
1174
+ },
1175
+ Accepted: {
1176
+ value: "Accepted",
1177
+ viewValue: "Pre autorizado"
1178
+ },
1179
+ Rejected: {
1180
+ value: "Rejected",
1181
+ viewValue: "Rechazado"
1182
+ },
1183
+ Idle: {
1184
+ value: "Idle",
1185
+ viewValue: ""
1186
+ },
1187
+ };
1188
+ var eContractSteps;
1189
+ (function (eContractSteps) {
1190
+ eContractSteps["idle"] = "idle";
1191
+ eContractSteps["general"] = "General";
1192
+ eContractSteps["address"] = "Address";
1193
+ eContractSteps["device"] = "Device";
1194
+ eContractSteps["financial"] = "Financial";
1195
+ eContractSteps["app"] = "App";
1196
+ })(eContractSteps || (eContractSteps = {}));
1197
+ const cIDCDataPii = {
1198
+ icc: "",
1199
+ rfc: "",
1200
+ sex: "",
1201
+ city: "",
1202
+ curp: "",
1203
+ days: "",
1204
+ imei: "",
1205
+ name: "",
1206
+ step: "",
1207
+ term: "",
1208
+ brand: "",
1209
+ email: "",
1210
+ model: "",
1211
+ phone: "",
1212
+ score: "",
1213
+ state: "",
1214
+ amount: "",
1215
+ colony: "",
1216
+ period: "",
1217
+ street: "",
1218
+ ticket: "",
1219
+ num_ext: "",
1220
+ num_int: "",
1221
+ zipcode: "",
1222
+ evidence: "",
1223
+ financed: "",
1224
+ house_is: "",
1225
+ lastname: "",
1226
+ type_job: "",
1227
+ birthdate: "",
1228
+ birthstate: "",
1229
+ dicio_data: "",
1230
+ dicio_step: "",
1231
+ secondname: "",
1232
+ nationality: "",
1233
+ seller_name: "",
1234
+ down_payment: "",
1235
+ municipality: "",
1236
+ score_no_hit: "",
1237
+ study_degree: "",
1238
+ branch_office: "",
1239
+ identity_data: "",
1240
+ interest_rate: "",
1241
+ score_interno: "",
1242
+ marital_status: "",
1243
+ monthly_income: "",
1244
+ motherlastname: "",
1245
+ score_rcc_fico: "",
1246
+ identity_selfie: "",
1247
+ amount_by_period: "",
1248
+ identity_id_back: "",
1249
+ proof_of_address: "",
1250
+ identity_id_front: "",
1251
+ economic_dependents: "",
1252
+ identity_id_request: "",
1253
+ identity_verification: "",
1254
+ is_address_ine_currently_live: "",
1255
+ fotografia_del_cliente_con_el_equipo: "",
1256
+ estado: "",
1257
+ gender: ""
1258
+ };
1259
+ /**
1260
+ * Base customer for create customer with DynamiCore provider
1261
+ * */
1262
+ const cIDCCustomer = {
1263
+ pii: cIDCDataPii,
1264
+ client_type: 662
1265
+ };
1266
+ const cIDCPayment = {
1267
+ operation: 98,
1268
+ account: "",
1269
+ date: "",
1270
+ amount: 0,
1271
+ dst_account: "",
1272
+ reference: ""
1273
+ };
1274
+ const cIDCCharge = {
1275
+ barcode_url: "",
1276
+ currency: "",
1277
+ expires_at: 0,
1278
+ object: "",
1279
+ quantity: 0,
1280
+ reference: "",
1281
+ service_name: "",
1282
+ store_name: "",
1283
+ type: "",
1284
+ unit_price: 0
1285
+ };
1286
+ const cIDCGeneratedReference = {
1287
+ account: 0,
1288
+ active: 0,
1289
+ amount: 0,
1290
+ channel: "",
1291
+ charge: cIDCCharge,
1292
+ company: 0,
1293
+ id: "",
1294
+ operation: 0
1295
+ };
1296
+ /**
1297
+ * Common Factory Dynamic
1298
+ * */
1299
+ class FactoryDynamiCore {
1300
+ static CreateReferenceBody(client, contract, dateTime) {
1301
+ const customerInfo = {
1302
+ name: client.name,
1303
+ email: client.email,
1304
+ phone: client.phone,
1305
+ };
1306
+ const customerItems = {
1307
+ name: "Referencia Oxxo",
1308
+ unit_price: contract.financial.weeklyPayment,
1309
+ quantity: 1
1310
+ };
1311
+ const paymentMethod = {
1312
+ type: "oxxo_cash"
1313
+ };
1314
+ if (!client.dynamic_account)
1315
+ return null;
1316
+ const body = {
1317
+ id: client.id,
1318
+ data: {
1319
+ account: Number(client.dynamic_account),
1320
+ operation: 98,
1321
+ customer_info: customerInfo,
1322
+ items: customerItems,
1323
+ payment_method: paymentMethod
1324
+ }
1325
+ };
1326
+ if (dateTime != undefined)
1327
+ body.date = dateTime;
1328
+ return body;
1329
+ }
1330
+ static CreateEmptyCustomer() {
1331
+ return cIDCCustomer;
1332
+ }
1333
+ static CreateCustomerFromOClient(client, contract) {
1334
+ const o = cIDCCustomer;
1335
+ o.pii.email = client.email;
1336
+ o.pii.name = client.name;
1337
+ o.pii.curp = client.curp;
1338
+ o.pii.phone = client.phone;
1339
+ o.pii.amount = String(contract.financial.total);
1340
+ o.pii.financed = String(contract.financial.financed);
1341
+ o.pii.amount_by_period = String(contract.financial.weeklyPayment);
1342
+ o.pii.zipcode = contract.address.zip;
1343
+ o.pii.street = contract.address.street;
1344
+ o.pii.city = contract.address.city;
1345
+ o.pii.state = contract.address.state;
1346
+ o.pii.colony = contract.address.neighbor;
1347
+ o.pii.num_ext = contract.address.ext;
1348
+ return o;
1349
+ }
1350
+ static CreateDynamicCredit(client, contract, clientDynamic) {
1351
+ const properties = {
1352
+ start_date: "",
1353
+ principal_disbursed: 0,
1354
+ expected_disbursed: 0,
1355
+ amount_commission_opening: 0
1356
+ };
1357
+ const config = {
1358
+ contract: `FP-${client.name}`,
1359
+ credit_type: "Arrendamiento",
1360
+ interest_rate: 528,
1361
+ installments: 0,
1362
+ periodicity: "WEEK",
1363
+ interest_base: "ACT/ACT",
1364
+ commission_opening: 40,
1365
+ financed_amount: contract.financial.financed,
1366
+ interest_arrears: 0
1367
+ };
1368
+ if (!client.dynamic_account)
1369
+ return null;
1370
+ return {
1371
+ id: Number(client.dynamic_account),
1372
+ group: clientDynamic.group,
1373
+ company: clientDynamic.company,
1374
+ client: clientDynamic.id,
1375
+ created_at: "",
1376
+ currency: "484",
1377
+ status: "pending",
1378
+ properties: properties,
1379
+ product: 1756,
1380
+ enabled: "1",
1381
+ config: config,
1382
+ amount: 0,
1383
+ type: "liabilities",
1384
+ identifier: null,
1385
+ start_at: null
1386
+ };
1387
+ }
1388
+ static CreatePayment(contract, clientDynamic) {
1389
+ return {
1390
+ account: String(clientDynamic.id),
1391
+ amount: contract.financial.weeklyPayment,
1392
+ date: "",
1393
+ dst_account: String(clientDynamic.id),
1394
+ external_id: "",
1395
+ extras: {},
1396
+ operation: 98,
1397
+ reference: ""
1398
+ };
1399
+ }
1400
+ static getNextDateTime() {
1401
+ const now = new Date();
1402
+ const nextDateTime = new Date(now.getTime() + 1000); // Add 1 second as an example
1403
+ const year = nextDateTime.getFullYear();
1404
+ const month = String(nextDateTime.getMonth() + 1).padStart(2, '0');
1405
+ const day = String(nextDateTime.getDate()).padStart(2, '0');
1406
+ const hours = String(nextDateTime.getHours()).padStart(2, '0');
1407
+ const minutes = String(nextDateTime.getMinutes()).padStart(2, '0');
1408
+ const seconds = String(nextDateTime.getSeconds()).padStart(2, '0');
1409
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
1410
+ }
1411
+ static getIsoDate() {
1412
+ const now = new Date();
1413
+ return now.toISOString();
1414
+ }
1415
+ static FormPayment(contract, account) {
1416
+ let data = FactoryDynamiCore.CreatePayment(contract, account);
1417
+ return {
1418
+ amount: new UntypedFormControl(data.amount, [Validators.required, Validators.min(0)]),
1419
+ };
1420
+ }
1421
+ }
1422
+
1423
+ var ePaymentType;
1424
+ (function (ePaymentType) {
1425
+ ePaymentType["OXXO"] = "OXXO";
1426
+ ePaymentType["ALTERNA"] = "ALTERNA";
1427
+ ePaymentType["OXXO_RECURRENT"] = "oxxo_recurrent";
1428
+ })(ePaymentType || (ePaymentType = {}));
1429
+ class FactoryConekta {
1430
+ static createOrder(client, contract, dateTime) {
1431
+ if (client.conekta_id == undefined)
1432
+ return {
1433
+ data: {
1434
+ charges: [],
1435
+ currency: "",
1436
+ customer_info: { customer_id: "" },
1437
+ line_items: []
1438
+ },
1439
+ id: ""
1440
+ };
1441
+ const customer_info = {
1442
+ customer_id: client.conekta_id
1443
+ };
1444
+ const week = ((3600 * 24) * 30) * 1000;
1445
+ let next = new Date().getTime() + week;
1446
+ next = Math.floor(next / 1000);
1447
+ const method = {
1448
+ type: "cash",
1449
+ expires_at: next,
1450
+ };
1451
+ const charge = {
1452
+ amount: contract.financial.weeklyPayment * 100,
1453
+ payment_method: method
1454
+ };
1455
+ const charges = [charge];
1456
+ const antifraud_info = {
1457
+ newKey: "Key"
1458
+ };
1459
+ const lineItem = {
1460
+ antifraud_info: antifraud_info,
1461
+ name: `Referencia credito ${client.name}`,
1462
+ quantity: 1,
1463
+ unit_price: contract.financial.weeklyPayment * 100,
1464
+ };
1465
+ const lineItems = [lineItem];
1466
+ const orderData = {
1467
+ customer_info: customer_info,
1468
+ charges: charges,
1469
+ currency: "MXN",
1470
+ line_items: lineItems
1471
+ };
1472
+ const order = {
1473
+ data: orderData,
1474
+ id: client.id
1475
+ };
1476
+ if (dateTime != undefined)
1477
+ order.date = dateTime;
1478
+ return order;
1479
+ }
1480
+ }
1481
+ // '
1482
+ // {
1483
+ // "customer_info": {
1484
+ // "name": "DevTest",
1485
+ // "email": "test@femsa.com",
1486
+ // "phone": "5522997233"
1487
+ // },
1488
+ // "currency": "MXN",
1489
+ // "line_items": [
1490
+ // {
1491
+ // "name": "Box of Cohiba S1s",
1492
+ // "quantity": 1,
1493
+ // "unit_price": 20000
1494
+ // }
1495
+ // ]
1496
+ // }
1497
+ // '
1498
+
1499
+ const ROUTE_NOTIFICATIONS = "notifications";
1500
+ const ROUTE_GLOBAL_REFERENCE2 = "/contract-reference";
1501
+ const prodFunction = "https://us-central1-ravcredit-2b079.cloudfunctions.net/CustomerNotification";
1502
+ const prodFunction2 = "https://customernotification-2imgfxveka-uc.a.run.app";
1503
+ const localTest = "http://127.0.0.1:5001/ravcredit-2b079/us-central1/CustomerNotification";
1504
+ const ravCreditFunctions = prodFunction;
1505
+ class FactoryNotification {
1506
+ static FormNotification(notification) {
1507
+ let data = cNotification;
1508
+ if (notification)
1509
+ data = notification;
1510
+ return {
1511
+ title: new UntypedFormControl(data.notification.title, [Validators.required, Validators.min(1)]),
1512
+ body: new UntypedFormControl(data.notification.body, [Validators.required, Validators.min(1)]),
1513
+ };
1514
+ }
1515
+ static CreateGlobalNotificationObj(data) {
1516
+ const o = {};
1517
+ if (data.notification) {
1518
+ const not = {};
1519
+ if (data.notification.body)
1520
+ not["body"] = data.notification.body;
1521
+ if (data.notification.title)
1522
+ not["title"] = data.notification.title;
1523
+ if (data.ids)
1524
+ not["ids"] = data.ids;
1525
+ if (data.tokens)
1526
+ not["tokens"] = data.tokens;
1527
+ if (data.type)
1528
+ not["type"] = data.type;
1529
+ if (data.data)
1530
+ if (data.data.route)
1531
+ not["route"] = data.data.route;
1532
+ o["data"] = not;
1533
+ }
1534
+ return o;
1535
+ }
1536
+ }
1537
+
1538
+ const keyUserID = "rc_uid";
1539
+ const dbVersion = 1;
1540
+ const dbName = "RavCreditDB";
1541
+ const keyPathId = "id";
1542
+ const dbAuthStore = "authStore";
1543
+ const dbUsersStore = "usersStore";
1544
+ const dbContractsStore = "contractsStore";
1545
+ const dbClientsStore = "clientsStore";
1546
+ const dbBusinessInfo = "businessInfo";
1547
+ const dbBusinessConfig = "businessConfig";
1548
+ const dbConektaClientsStore = "conektaClientsStore";
1549
+ const dbConektaReferencesStore = "conektaReferencesStore";
1550
+ const dbPassportReferencesStore = "passportReferencesStore";
1551
+ const dbDynamicReferencesStore = "dynamicReferencesStore";
1552
+ const dbDynamicAccountStore = "dynamicAccountStore";
1553
+ const dbNotificationsStore = "notificationsStore";
1554
+ const dbPaymentsStore = "paymentsStore";
1555
+ const dbIndexAuth = "iAuth";
1556
+ const dbIndexUsers = "iUsers";
1557
+ const dbIndexContracts = "iContracts";
1558
+ const dbIndexClients = "iClients";
1559
+ const dbIndexBusiness = "iBusiness";
1560
+ const dbIndexConektaClients = "iConecktaClients";
1561
+ const dbIndexConektaClientsRef = "iConecktaClientsRef";
1562
+ const dbIndexPassportClientsRef = "iPassportClientsRef";
1563
+ const dbIndexNotification = "iNotification";
1564
+ const dbIndexPayments = "iNotification";
1565
+ const dateFormat = "EEEE, dd MMM yyyy";
1566
+ const dateCompleteFormat = "EEEE, dd MMM yyyy hh:mm aaaa";
1567
+ const timeFormat = "hh:mm aaaa";
1568
+ const expiredPayment = "expiredPayment";
1569
+
1570
+ class IndexedDbService {
1571
+ indexDbStatus = false;
1572
+ iDb;
1573
+ constructor() {
1574
+ }
1575
+ // async dbAuthorization() {
1576
+ // // const k = this.getLocalUser()
1577
+ // // if (k == null) return false
1578
+ // //
1579
+ // // const db = await openDB(dbName, dbVersion)
1580
+ // // // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1581
+ // // const auth = await db.get(dbAuthStore, k)
1582
+ // // // utils auth = await store.get(k)
1583
+ // // db.close()
1584
+ //
1585
+ // let auth: any = null
1586
+ // return auth;
1587
+ //
1588
+ // }
1589
+ /****************** SIMPLE Transactional - CRUD *************************************/
1590
+ async dbGetObject(store, data) {
1591
+ if (!data)
1592
+ return data;
1593
+ const db = await openDB(dbName, dbVersion);
1594
+ return await db.get(store, data);
1595
+ }
1596
+ async dbGetAllByStore(store, index) {
1597
+ const db = await openDB(dbName, dbVersion);
1598
+ return await db.getAll(store);
1599
+ }
1600
+ async dbAddObject(store, data) {
1601
+ try {
1602
+ const db = await openDB(dbName, dbVersion);
1603
+ await db.put(store, data);
1604
+ return true;
1605
+ }
1606
+ catch (e) {
1607
+ return false;
1608
+ }
1609
+ }
1610
+ async dbRemoveObject(store, data) {
1611
+ const db = await openDB(dbName, dbVersion);
1612
+ return await db.delete(store, data);
1613
+ }
1614
+ /************************************* AUTH **************************************/
1615
+ async dbSignIn(store, data) {
1616
+ await this.iDb.put(store, data);
1617
+ const _data = data;
1618
+ this.setLocalStorage(keyUserID, _data.id);
1619
+ }
1620
+ async dbSignOut() {
1621
+ const k = this.getLocalUser();
1622
+ if (!k)
1623
+ return;
1624
+ await this.iDb.delete(dbAuthStore, k);
1625
+ this.removeLocalStorage(keyUserID);
1626
+ }
1627
+ async dbAuthorization() {
1628
+ const k = this.getLocalUser();
1629
+ if (k == null)
1630
+ return false;
1631
+ const db = await openDB(dbName, dbVersion);
1632
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1633
+ const auth = await db.get(dbAuthStore, k);
1634
+ // utils auth = await store.get(k)
1635
+ db.close();
1636
+ if (!auth)
1637
+ return false;
1638
+ else
1639
+ return true;
1640
+ }
1641
+ async dbGetToken() {
1642
+ const k = this.getLocalUser();
1643
+ if (k == null)
1644
+ return "";
1645
+ const db = await openDB(dbName, dbVersion);
1646
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1647
+ const auth = await db.get(dbAuthStore, k);
1648
+ // utils auth = await store.get(k)
1649
+ db.close();
1650
+ return auth.access_token != "" ? auth.access_token : "";
1651
+ }
1652
+ /******************************** Local Storage *************************************/
1653
+ setLocalStorage(k, v) {
1654
+ localStorage.setItem(k, v);
1655
+ }
1656
+ getLocalStorage(k) {
1657
+ return localStorage.getItem(k);
1658
+ }
1659
+ removeLocalStorage(k) {
1660
+ return localStorage.removeItem(k);
1661
+ }
1662
+ getLocalUser() {
1663
+ const k = localStorage.getItem(keyUserID);
1664
+ return (k);
1665
+ }
1666
+ /********************************************************************************* **/
1667
+ async getPlatformUser() {
1668
+ const k = this.getLocalStorage(keyUserID);
1669
+ if (k == null)
1670
+ return "";
1671
+ const db = await openDB(dbName, dbVersion);
1672
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1673
+ const auth = await db.get(dbAuthStore, k);
1674
+ // utils auth = await store.get(k)
1675
+ db.close();
1676
+ return auth.name != "" ? auth.name : "";
1677
+ }
1678
+ async getToken() {
1679
+ const k = this.getLocalUser();
1680
+ if (k == null)
1681
+ return "";
1682
+ const db = await openDB(dbName, dbVersion);
1683
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1684
+ const auth = await db.get(dbAuthStore, k);
1685
+ // utils auth = await store.get(k)
1686
+ db.close();
1687
+ return auth.access_token != "" ? auth.access_token : "";
1688
+ }
1689
+ async addObject(store, data) {
1690
+ try {
1691
+ const db = await openDB(dbName, dbVersion);
1692
+ await db.put(store, data);
1693
+ return true;
1694
+ }
1695
+ catch (e) {
1696
+ return false;
1697
+ }
1698
+ }
1699
+ async patchObject(store, data) {
1700
+ try {
1701
+ const db = await openDB(dbName, dbVersion);
1702
+ const txn = db.transaction(store, "readwrite");
1703
+ const obj = txn.objectStore(store);
1704
+ // const index = obj.index(keyPathCurp)
1705
+ await obj.put(data);
1706
+ return data;
1707
+ }
1708
+ catch (e) {
1709
+ console.error(e);
1710
+ return {};
1711
+ }
1712
+ }
1713
+ async updateObjectByID(store, id, data) {
1714
+ try {
1715
+ const db = await openDB(dbName, dbVersion);
1716
+ const res = await db.get(store, id);
1717
+ if (res != undefined)
1718
+ await this.removeObject(dbClientsStore, id);
1719
+ return await this.addObject(store, data);
1720
+ }
1721
+ catch (e) {
1722
+ console.error("updateObjectByID Catch Error:", e);
1723
+ return false;
1724
+ }
1725
+ }
1726
+ async upsertObjectById(store, id, data) {
1727
+ const db = await openDB(dbName, dbVersion);
1728
+ const res = await db.get(store, id);
1729
+ if (res)
1730
+ await this.removeObject(store, id);
1731
+ return await db.add(store, data);
1732
+ }
1733
+ async removeObject(store, data) {
1734
+ const db = await openDB(dbName, dbVersion);
1735
+ return await db.delete(store, data);
1736
+ }
1737
+ async deleteObjectByID(store, id) {
1738
+ try {
1739
+ const db = await openDB(dbName, dbVersion);
1740
+ const txn = db.transaction(store, "readwrite");
1741
+ const obj = txn.objectStore(store);
1742
+ const index = obj.index(keyPathId);
1743
+ const va2 = index.openCursor(id);
1744
+ va2.then(async (cursor) => {
1745
+ while (cursor) {
1746
+ cursor.delete();
1747
+ cursor = await cursor.continue();
1748
+ }
1749
+ });
1750
+ return va2;
1751
+ }
1752
+ catch (e) {
1753
+ console.error(e);
1754
+ return {};
1755
+ }
1756
+ }
1757
+ async cleanAll(store) {
1758
+ const db = await openDB(dbName, dbVersion);
1759
+ return await db.clear(store);
1760
+ }
1761
+ async getObject(store, data) {
1762
+ if (!data)
1763
+ return data;
1764
+ const db = await openDB(dbName, dbVersion);
1765
+ return await db.get(store, data);
1766
+ }
1767
+ async addBuildByStore(store, data) {
1768
+ for (const o of data) {
1769
+ const exists = await this.getObject(store, o["id"]);
1770
+ if (!exists)
1771
+ await this.addObject(store, o);
1772
+ else
1773
+ await this.updateObject(store, o);
1774
+ }
1775
+ }
1776
+ async updateObject(store, data) {
1777
+ const db = await openDB(dbName, dbVersion);
1778
+ await db.put(store, data);
1779
+ }
1780
+ async getAllByStore(store, index) {
1781
+ const db = await openDB(dbName, dbVersion);
1782
+ return await db.getAll(store);
1783
+ }
1784
+ async getAuthUser() {
1785
+ const data = await this.getAllByStore(dbAuthStore);
1786
+ return data[0];
1787
+ }
1788
+ async getAuthName() {
1789
+ const data = await this.getAuthUser();
1790
+ return data.name;
1791
+ }
1792
+ async getAuthUsername() {
1793
+ const data = await this.getAuthUser();
1794
+ return data.username;
1795
+ }
1796
+ async saveDataLocally(contract, client, providerData) {
1797
+ try {
1798
+ await this.addObject(dbClientsStore, client);
1799
+ await this.addObject(dbContractsStore, contract);
1800
+ if (!providerData)
1801
+ return false;
1802
+ if (contract.financial.provider === eProvider.Conekta) {
1803
+ await this.addObject(dbConektaClientsStore, providerData);
1804
+ await this.addObject(dbConektaReferencesStore, providerData);
1805
+ }
1806
+ else if (contract.financial.provider === eProvider.Passport) {
1807
+ await this.addObject(dbPassportReferencesStore, providerData);
1808
+ }
1809
+ else if (contract.financial.provider === eProvider.DynamiCore) {
1810
+ await this.addObject(dbDynamicReferencesStore, providerData);
1811
+ }
1812
+ return true;
1813
+ }
1814
+ catch (e) {
1815
+ console.error(e);
1816
+ return false;
1817
+ }
1818
+ }
1819
+ /******************** MERGE **************************************/
1820
+ async getAllClientContracts() {
1821
+ const clientContract = [];
1822
+ const clients = await this.getAllByStore(dbClientsStore);
1823
+ if (clients.length == 0)
1824
+ return [];
1825
+ for (let client of clients) {
1826
+ const contract = await this.getObject(dbContractsStore, client.contract);
1827
+ const e = { ...client, ...contract };
1828
+ // preserve the id value over concat models
1829
+ e.id = client.id;
1830
+ e.status = client.status;
1831
+ clientContract.push(e);
1832
+ }
1833
+ return clientContract;
1834
+ }
1835
+ /******************** MERGE **************************************/
1836
+ async dbGetAllClientContracts() {
1837
+ const clientContract = [];
1838
+ const clients = await this.dbGetAllByStore(dbClientsStore);
1839
+ if (clients.length == 0)
1840
+ return [];
1841
+ for (let client of clients) {
1842
+ const contract = await this.dbGetObject(dbContractsStore, client.contract);
1843
+ const e = { ...client, ...contract };
1844
+ // preserve the id value over concat models
1845
+ e.id = client.id;
1846
+ e.status = client.status;
1847
+ clientContract.push(e);
1848
+ }
1849
+ return clientContract;
1850
+ }
1851
+ /****************** BUSINESS INFO *************************************/
1852
+ async getBusinessInfo() {
1853
+ const config = await this.dbGetAllByStore(dbBusinessInfo);
1854
+ if (!config)
1855
+ return null;
1856
+ return config[0];
1857
+ }
1858
+ /****************** BUSINESS CONFIG ************************************/
1859
+ async getBusinessConfig() {
1860
+ const config = await this.dbGetAllByStore(dbBusinessConfig);
1861
+ if (!config)
1862
+ return null;
1863
+ return config[0];
1864
+ }
1865
+ async updateBusinessConfig(config) {
1866
+ // config.version = "1.0"
1867
+ await this.dbRemoveObject(dbBusinessConfig, "1.0");
1868
+ await this.dbAddObject(dbBusinessConfig, config);
1869
+ }
1870
+ async updateBusinessInfo(config) {
1871
+ config.version = "v2024";
1872
+ await this.dbRemoveObject(dbBusinessInfo, "v2024");
1873
+ await this.dbAddObject(dbBusinessInfo, config);
1874
+ }
1875
+ /**************** NOTIFICATIONS *********************************/
1876
+ async getLocalNotifications() {
1877
+ const notifications = await this.dbGetAllByStore(dbNotificationsStore);
1878
+ if (!notifications)
1879
+ return null;
1880
+ return notifications;
1881
+ }
1882
+ async updateNotifications(notifications) {
1883
+ for (const o of notifications) {
1884
+ const exists = await this.dbGetObject(dbNotificationsStore, o.notification_id);
1885
+ if (!exists) {
1886
+ await this.dbAddObject(dbNotificationsStore, o);
1887
+ }
1888
+ }
1889
+ }
1890
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1891
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, providedIn: 'root' });
1892
+ }
1893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, decorators: [{
1894
+ type: Injectable,
1895
+ args: [{
1896
+ providedIn: 'root'
1897
+ }]
1898
+ }], ctorParameters: () => [] });
1899
+
1900
+ class UtilTime {
1901
+ localeFns = es;
1902
+ static IsExpired(time) {
1903
+ const dateInit = new Date(time);
1904
+ const dayInit = dateInit.getDate();
1905
+ const monthInit = dateInit.getMonth() + 1;
1906
+ const dateActual = new Date();
1907
+ const dayActual = dateActual.getDate();
1908
+ const monthActual = dateActual.getMonth() + 1;
1909
+ if (monthActual > monthInit)
1910
+ return true;
1911
+ return dayActual > dayInit;
1912
+ }
1913
+ static getDates(initial, weeks) {
1914
+ const dates = [];
1915
+ let prev = initial;
1916
+ for (let i = 0; i < weeks; i++) {
1917
+ const date = add(prev, { weeks: 1 });
1918
+ dates.push({
1919
+ week: i + 1,
1920
+ date: date.getTime()
1921
+ });
1922
+ prev = date.getTime();
1923
+ }
1924
+ return dates;
1925
+ }
1926
+ static getPreviousWeek() {
1927
+ const today = new Date().getTime();
1928
+ const week = ((3600 * 24) * 7) * 1000;
1929
+ return today - week;
1930
+ }
1931
+ static getDayNum(date) {
1932
+ return getDate(date);
1933
+ }
1934
+ static getDayName(date) {
1935
+ return format(date, "EEEE", { locale: es });
1936
+ }
1937
+ static getMonthName(date) {
1938
+ return format(date, "MMMM", { locale: es }).toUpperCase();
1939
+ }
1940
+ static getYear(date) {
1941
+ return format(date, "yyyy");
1942
+ }
1943
+ static GetNextPayment(time, provider) {
1944
+ let week = 0;
1945
+ if (provider == eProvider.Conekta) {
1946
+ week = (((3600 * 24) * 7));
1947
+ }
1948
+ else if (provider == eProvider.DynamiCore) {
1949
+ week = (((3600 * 24) * 7) * 1000);
1950
+ }
1951
+ return this.getLocalTimeFromLong(time + week, provider);
1952
+ }
1953
+ static getLocalTimeFromLong(time, provider) {
1954
+ if (time <= 0)
1955
+ return "";
1956
+ let factor = this.GetFactor(provider);
1957
+ let dateTime = time * factor;
1958
+ let parsedDate = format(new Date(dateTime), dateFormat, {
1959
+ locale: es
1960
+ });
1961
+ return parsedDate;
1962
+ }
1963
+ static DelayPaymentLast(lastPayment, provider, injector) {
1964
+ let factor = this.GetFactor(provider);
1965
+ let now = new Date().getTime();
1966
+ let last = 0;
1967
+ if (provider == eProvider.Conekta)
1968
+ last = ((((3600 * 24) * 7)) + lastPayment) * factor;
1969
+ else if (provider == eProvider.DynamiCore)
1970
+ last = ((((3600 * 24) * 7) * 1000) + lastPayment) * factor;
1971
+ runInInjectionContext(injector, () => {
1972
+ const idb = inject(IndexedDbService);
1973
+ // const observable = inject(ObservablesService)
1974
+ idb.setLocalStorage(expiredPayment, String(now > last));
1975
+ // observable.isLate.next(now > last)
1976
+ });
1977
+ return now > last;
1978
+ }
1979
+ static GetFactor(provider) {
1980
+ let factor = 1;
1981
+ if (provider == eProvider.Conekta)
1982
+ factor = 1000;
1983
+ return factor;
1984
+ }
1985
+ static GetEpochFromFormatedDate(date) {
1986
+ if (date == "")
1987
+ return 0;
1988
+ const _date = new Date(date);
1989
+ if (isNaN(_date.getTime()))
1990
+ return 0;
1991
+ return _date.getTime();
1992
+ }
1993
+ static GetTimeFromString(date) {
1994
+ return format(new Date(date), timeFormat, {
1995
+ locale: es
1996
+ });
1997
+ }
1998
+ static GetDateFromString(date) {
1999
+ return format(new Date(date), dateCompleteFormat, {
2000
+ locale: es
2001
+ });
2002
+ }
2003
+ // Quick sort
2004
+ static SortingByTime(payments) {
2005
+ if (payments.length <= 1)
2006
+ return payments;
2007
+ const pivot = payments[payments.length - 1];
2008
+ const pivotDate = new Date(pivot.created).getTime();
2009
+ const left = [];
2010
+ const right = [];
2011
+ for (let i = 0; i < payments.length - 1; i++) {
2012
+ const actualDate = new Date(payments[i].created).getTime();
2013
+ if (actualDate > pivotDate)
2014
+ left.push(payments[i]);
2015
+ else
2016
+ right.push(payments[i]);
2017
+ }
2018
+ return [...this.SortingByTime(left), pivot, ...this.SortingByTime(right)];
2019
+ }
2020
+ static SortingByTimeConekta(payments) {
2021
+ if (payments.length <= 1)
2022
+ return payments;
2023
+ const pivot = payments[payments.length - 1];
2024
+ let pivotDate = 0;
2025
+ if (pivot.charges.data == undefined)
2026
+ return payments;
2027
+ if (pivot.charges.data[0].paid_at != undefined) {
2028
+ pivotDate = pivot.charges.data[0].paid_at;
2029
+ }
2030
+ else {
2031
+ pivot.charges.data[0].created_at;
2032
+ }
2033
+ if (pivotDate <= 0)
2034
+ return payments;
2035
+ const left = [];
2036
+ const right = [];
2037
+ for (let i = 0; i < payments.length - 1; i++) {
2038
+ const actual = payments[i].charges.data[0].paid_at;
2039
+ if (actual <= 0)
2040
+ continue;
2041
+ if (actual > pivotDate)
2042
+ left.push(payments[i]);
2043
+ else
2044
+ right.push(payments[i]);
2045
+ }
2046
+ return [...this.SortingByTimeConekta(left), pivot, ...this.SortingByTimeConekta(right)];
2047
+ }
2048
+ }
2049
+
2050
+ const cContractMetrics = {
2051
+ total: 0,
2052
+ activated: 0,
2053
+ paused: 0,
2054
+ completed: 0,
2055
+ canceled: 0,
2056
+ late: 0,
2057
+ conektaCount: 0,
2058
+ dynamicCount: 0,
2059
+ passportCount: 0,
2060
+ rateTotal: 0,
2061
+ rateActive: 0,
2062
+ ratePaused: 0,
2063
+ rateComplete: 0,
2064
+ rateCanceled: 0,
2065
+ rateLate: 0
2066
+ };
2067
+
2068
+ class FactoryPassport {
2069
+ static CreatePassportReference(client, contract, dateTime) {
2070
+ const o = {
2071
+ passport: {
2072
+ type: ePassportTypes.CREATE,
2073
+ data: {
2074
+ name: client.name,
2075
+ email: client.email,
2076
+ amount: contract.financial.weeklyPayment,
2077
+ expirationDate: "",
2078
+ additional: {
2079
+ client: client.name,
2080
+ clientID: client.id,
2081
+ credit: client.status
2082
+ }
2083
+ }
2084
+ },
2085
+ contract: contract,
2086
+ date: dateTime
2087
+ };
2088
+ if (dateTime != undefined)
2089
+ o.date = dateTime;
2090
+ return o;
2091
+ }
2092
+ }
2093
+
2094
+ class FactoryPayment {
2095
+ static CreatePayment(data, provider) {
2096
+ const o = {};
2097
+ if (provider == eProvider.DynamiCore)
2098
+ o.dynamicPayment = data;
2099
+ if (provider == eProvider.Conekta)
2100
+ o.conektaPayment = data;
2101
+ return o;
2102
+ }
2103
+ }
2104
+
2105
+ var eAssetPeriod;
2106
+ (function (eAssetPeriod) {
2107
+ eAssetPeriod["MONTH"] = "MONTH";
2108
+ eAssetPeriod["WEEK"] = "WEEK";
2109
+ })(eAssetPeriod || (eAssetPeriod = {}));
2110
+
2111
+ /*
2112
+ * Public API Surface of ravcredit-lib
2113
+ */
2114
+
2115
+ /**
2116
+ * Generated bundle index. Do not edit.
2117
+ */
2118
+
2119
+ export { FactoryBusiness, FactoryClient, FactoryConekta, FactoryContract, FactoryDynamiCore, FactoryNotification, FactoryPassport, FactoryPayment, IndexedDbService, ROUTE_GLOBAL_REFERENCE2, ROUTE_NOTIFICATIONS, RavcreditLibComponent, RavcreditLibService, UtilTime, UtilsHttp, cAddress, cAuthConfig, cBusinessConfig, cBusinessDeadlines, cBusinessInfo, cClient, cClientConekta, cClientContract, cClientDynamicStatus, cConektaRecurrent, cContract, cContractMetrics, cDefinedSchedule, cDevice, cEmptyDay, cFinancial, cIDCCharge, cIDCCustomer, cIDCDataPii, cIDCGeneratedReference, cIDCPayment, cNotification, cOptionsClientStatus, cOxxoRecurrentSources, cOxxorecurrentSourcesData, cPaymentDalay, cSchedule, cSingleOptionClientStatus, cTopic, cTyClientContract, cUserReference, dateCompleteFormat, dateFormat, dbAuthStore, dbBusinessConfig, dbBusinessInfo, dbClientsStore, dbConektaClientsStore, dbConektaReferencesStore, dbContractsStore, dbDynamicAccountStore, dbDynamicReferencesStore, dbIndexAuth, dbIndexBusiness, dbIndexClients, dbIndexConektaClients, dbIndexConektaClientsRef, dbIndexContracts, dbIndexNotification, dbIndexPassportClientsRef, dbIndexPayments, dbIndexUsers, dbName, dbNotificationsStore, dbPassportReferencesStore, dbPaymentsStore, dbUsersStore, dbVersion, eAccountDynamicStatus, eAssetPeriod, eAuthActions, eAuthType, eClientDynamicStatus, eClientStatus, eConektaOrderStatus, eConektaRes, eContractStatus, eContractSteps, eIdentityTypes, eLoginStatus, eNotificationType, ePassportTypes, ePaymentType, eProcessStatus, eProvider, eReferenceStatusRav, eRoles, eRolesSelect, eVerificationChannel, eVerificationStatus, eVerificationStep, expiredPayment, keyPathId, keyUserID, ravCreditFunctions, snackBarConfigAction, snackBarConfigNoAction, snackBarConfigNoActionLong, timeFormat, week };
2120
+ //# sourceMappingURL=ravcredit-lib.mjs.map