ravcredit-lib 0.0.11 → 0.0.12

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