ravcredit-lib 0.0.3 → 0.0.5

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 (49) hide show
  1. package/fesm2022/ravcredit-lib.mjs +551 -24
  2. package/fesm2022/ravcredit-lib.mjs.map +1 -1
  3. package/index.d.ts +1516 -4
  4. package/package.json +3 -4
  5. package/esm2022/lib/ravcredit-lib.component.mjs +0 -19
  6. package/esm2022/lib/ravcredit-lib.service.mjs +0 -14
  7. package/esm2022/lib/v1/objects/oAddress.mjs +0 -2
  8. package/esm2022/lib/v1/objects/oBusiness.mjs +0 -2
  9. package/esm2022/lib/v1/objects/oClient.mjs +0 -2
  10. package/esm2022/lib/v1/objects/oConekta.mjs +0 -85
  11. package/esm2022/lib/v1/objects/oContract.mjs +0 -2
  12. package/esm2022/lib/v1/objects/oContractAll.mjs +0 -2
  13. package/esm2022/lib/v1/objects/oCustomer.mjs +0 -18
  14. package/esm2022/lib/v1/objects/oDevice.mjs +0 -2
  15. package/esm2022/lib/v1/objects/oFinancial.mjs +0 -2
  16. package/esm2022/lib/v1/objects/oGlobal.mjs +0 -86
  17. package/esm2022/lib/v1/objects/oLogIn.mjs +0 -17
  18. package/esm2022/lib/v1/objects/oNewPayment.mjs +0 -2
  19. package/esm2022/lib/v1/objects/oNotification.mjs +0 -17
  20. package/esm2022/lib/v1/objects/oPassport.mjs +0 -7
  21. package/esm2022/lib/v1/objects/oUser.mjs +0 -2
  22. package/esm2022/lib/v1/util/UtilBusiness.mjs +0 -181
  23. package/esm2022/lib/v1/util/UtilClient.mjs +0 -221
  24. package/esm2022/lib/v1/util/UtilContract.mjs +0 -339
  25. package/esm2022/lib/v1/util/UtilDynamiCore.mjs +0 -292
  26. package/esm2022/public-api.mjs +0 -21
  27. package/esm2022/ravcredit-lib.mjs +0 -5
  28. package/lib/ravcredit-lib.component.d.ts +0 -5
  29. package/lib/ravcredit-lib.service.d.ts +0 -6
  30. package/lib/v1/objects/oAddress.d.ts +0 -9
  31. package/lib/v1/objects/oBusiness.d.ts +0 -101
  32. package/lib/v1/objects/oClient.d.ts +0 -43
  33. package/lib/v1/objects/oConekta.d.ts +0 -305
  34. package/lib/v1/objects/oContract.d.ts +0 -23
  35. package/lib/v1/objects/oContractAll.d.ts +0 -21
  36. package/lib/v1/objects/oCustomer.d.ts +0 -17
  37. package/lib/v1/objects/oDevice.d.ts +0 -5
  38. package/lib/v1/objects/oFinancial.d.ts +0 -30
  39. package/lib/v1/objects/oGlobal.d.ts +0 -149
  40. package/lib/v1/objects/oLogIn.d.ts +0 -30
  41. package/lib/v1/objects/oNewPayment.d.ts +0 -11
  42. package/lib/v1/objects/oNotification.d.ts +0 -25
  43. package/lib/v1/objects/oPassport.d.ts +0 -55
  44. package/lib/v1/objects/oUser.d.ts +0 -25
  45. package/lib/v1/util/UtilBusiness.d.ts +0 -54
  46. package/lib/v1/util/UtilClient.d.ts +0 -34
  47. package/lib/v1/util/UtilContract.d.ts +0 -71
  48. package/lib/v1/util/UtilDynamiCore.d.ts +0 -453
  49. package/public-api.d.ts +0 -17
@@ -1,6 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component } from '@angular/core';
3
3
  import { UntypedFormControl, Validators, UntypedFormArray } from '@angular/forms';
4
+ import { openDB } from 'idb';
4
5
 
5
6
  class RavcreditLibService {
6
7
  constructor() { }
@@ -31,6 +32,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
31
32
  ` }]
32
33
  }] });
33
34
 
35
+ const cAddress = {
36
+ street: "",
37
+ city: "",
38
+ neighbor: "",
39
+ zip: "",
40
+ ext: "",
41
+ int: "",
42
+ state: ""
43
+ };
44
+
34
45
  var eConektaRes;
35
46
  (function (eConektaRes) {
36
47
  eConektaRes["CUSTOMER_CREATED"] = "customer.created";
@@ -351,17 +362,6 @@ class FactoryClient {
351
362
  }
352
363
  }
353
364
 
354
- // TODO **************************************** DELETE
355
- const cAddress$1 = {
356
- street: "",
357
- city: "",
358
- neighbor: "",
359
- zip: "",
360
- ext: "",
361
- int: "",
362
- state: ""
363
- };
364
- // TODO **************************************** DELETE
365
365
  const cSchedule = {
366
366
  day: "",
367
367
  open: 0,
@@ -385,7 +385,7 @@ const cDefinedSchedule = [
385
385
  const cBusinessInfo = {
386
386
  version: "v2024",
387
387
  name: "",
388
- address: cAddress$1,
388
+ address: cAddress,
389
389
  phones: [],
390
390
  email: "",
391
391
  };
@@ -413,7 +413,7 @@ class FactoryBusiness {
413
413
  if (info)
414
414
  data = info;
415
415
  if (!info?.address)
416
- data.address = cAddress$1;
416
+ data.address = cAddress;
417
417
  return {
418
418
  name: new UntypedFormControl(data.name, Validators.required),
419
419
  email: new UntypedFormControl(data.email, [Validators.required, Validators.email]),
@@ -443,7 +443,7 @@ class FactoryBusiness {
443
443
  };
444
444
  }
445
445
  static CreateBusinessInfoObj(data) {
446
- const address = cAddress$1;
446
+ const address = cAddress;
447
447
  const schedule = {
448
448
  monday: {},
449
449
  tuesday: {},
@@ -563,15 +563,6 @@ const cFinancial = {
563
563
  commission_opening: 0,
564
564
  interest_arrears: 0,
565
565
  };
566
- const cAddress = {
567
- street: "",
568
- city: "",
569
- neighbor: "",
570
- zip: "",
571
- ext: "",
572
- int: "",
573
- state: ""
574
- };
575
566
  const cContract = {
576
567
  id: "",
577
568
  client: "",
@@ -991,6 +982,542 @@ var ePassportTypes;
991
982
  })(ePassportTypes || (ePassportTypes = {}));
992
983
  /** ******************************** */
993
984
 
985
+ var eReferenceStatusRav;
986
+ (function (eReferenceStatusRav) {
987
+ eReferenceStatusRav["Disponible"] = "Disponible";
988
+ eReferenceStatusRav["Active"] = "Activo con credito vigente";
989
+ eReferenceStatusRav["ActiveEnded"] = "Activo sin credito vigente";
990
+ eReferenceStatusRav["Registered"] = "Registrado";
991
+ eReferenceStatusRav["NonRegistered"] = "No registrado";
992
+ eReferenceStatusRav["NonVerified"] = "No verificado";
993
+ eReferenceStatusRav["Rejected"] = "Rechazado";
994
+ eReferenceStatusRav["Pending"] = "Pendiente";
995
+ })(eReferenceStatusRav || (eReferenceStatusRav = {}));
996
+ var eAccountDynamicStatus;
997
+ (function (eAccountDynamicStatus) {
998
+ eAccountDynamicStatus["OK"] = "Con cuenta activa";
999
+ eAccountDynamicStatus["NOK"] = "Sin cuenta activa";
1000
+ })(eAccountDynamicStatus || (eAccountDynamicStatus = {}));
1001
+ //
1002
+ // export enum eAccountDynamicRegister {
1003
+ // "Active" = "Activo", // Ok
1004
+ // "NonAuthorized" = "No autorizado",
1005
+ // "Authorized" = "Autorizado", // Non ref
1006
+ // "Accepted" = "Aceptado", // Non ref
1007
+ // "Rejected" = "Rechazado", // Non ref
1008
+ // "Pending" = "Pendiente", // Non ref
1009
+ // "NotFound" = "No registrado"
1010
+ // }
1011
+ var eClientDynamicStatus;
1012
+ (function (eClientDynamicStatus) {
1013
+ eClientDynamicStatus["Active"] = "Active";
1014
+ eClientDynamicStatus["Pending"] = "Pending";
1015
+ eClientDynamicStatus["Accepted"] = "Accepted";
1016
+ eClientDynamicStatus["Rejected"] = "Rejected";
1017
+ eClientDynamicStatus["approved"] = "Aprobado";
1018
+ })(eClientDynamicStatus || (eClientDynamicStatus = {}));
1019
+ const cClientDynamicStatus = {
1020
+ Active: {
1021
+ value: "Active",
1022
+ viewValue: "Activo"
1023
+ },
1024
+ Pending: {
1025
+ value: "Pending",
1026
+ viewValue: "Pendiente"
1027
+ },
1028
+ Accepted: {
1029
+ value: "Accepted",
1030
+ viewValue: "Pre autorizado"
1031
+ },
1032
+ Rejected: {
1033
+ value: "Rejected",
1034
+ viewValue: "Rechazado"
1035
+ },
1036
+ Idle: {
1037
+ value: "Idle",
1038
+ viewValue: ""
1039
+ },
1040
+ };
1041
+ var eContractSteps;
1042
+ (function (eContractSteps) {
1043
+ eContractSteps["idle"] = "idle";
1044
+ eContractSteps["general"] = "General";
1045
+ eContractSteps["address"] = "Address";
1046
+ eContractSteps["device"] = "Device";
1047
+ eContractSteps["financial"] = "Financial";
1048
+ eContractSteps["app"] = "App";
1049
+ })(eContractSteps || (eContractSteps = {}));
1050
+ const cIDCDataPii = {
1051
+ icc: "",
1052
+ rfc: "",
1053
+ sex: "",
1054
+ city: "",
1055
+ curp: "",
1056
+ days: "",
1057
+ imei: "",
1058
+ name: "",
1059
+ step: "",
1060
+ term: "",
1061
+ brand: "",
1062
+ email: "",
1063
+ model: "",
1064
+ phone: "",
1065
+ score: "",
1066
+ state: "",
1067
+ amount: "",
1068
+ colony: "",
1069
+ period: "",
1070
+ street: "",
1071
+ ticket: "",
1072
+ num_ext: "",
1073
+ num_int: "",
1074
+ zipcode: "",
1075
+ evidence: "",
1076
+ financed: "",
1077
+ house_is: "",
1078
+ lastname: "",
1079
+ type_job: "",
1080
+ birthdate: "",
1081
+ birthstate: "",
1082
+ dicio_data: "",
1083
+ dicio_step: "",
1084
+ secondname: "",
1085
+ nationality: "",
1086
+ seller_name: "",
1087
+ down_payment: "",
1088
+ municipality: "",
1089
+ score_no_hit: "",
1090
+ study_degree: "",
1091
+ branch_office: "",
1092
+ identity_data: "",
1093
+ interest_rate: "",
1094
+ score_interno: "",
1095
+ marital_status: "",
1096
+ monthly_income: "",
1097
+ motherlastname: "",
1098
+ score_rcc_fico: "",
1099
+ identity_selfie: "",
1100
+ amount_by_period: "",
1101
+ identity_id_back: "",
1102
+ proof_of_address: "",
1103
+ identity_id_front: "",
1104
+ economic_dependents: "",
1105
+ identity_id_request: "",
1106
+ identity_verification: "",
1107
+ is_address_ine_currently_live: "",
1108
+ fotografia_del_cliente_con_el_equipo: "",
1109
+ estado: "",
1110
+ gender: ""
1111
+ };
1112
+ /**
1113
+ * Base customer for create customer with DynamiCore provider
1114
+ * */
1115
+ const cIDCCustomer = {
1116
+ pii: cIDCDataPii,
1117
+ client_type: 662
1118
+ };
1119
+ const cIDCPayment = {
1120
+ operation: 98,
1121
+ account: "",
1122
+ date: "",
1123
+ amount: 0,
1124
+ dst_account: "",
1125
+ reference: ""
1126
+ };
1127
+ const cIDCCharge = {
1128
+ barcode_url: "",
1129
+ currency: "",
1130
+ expires_at: 0,
1131
+ object: "",
1132
+ quantity: 0,
1133
+ reference: "",
1134
+ service_name: "",
1135
+ store_name: "",
1136
+ type: "",
1137
+ unit_price: 0
1138
+ };
1139
+ const cIDCGeneratedReference = {
1140
+ account: 0,
1141
+ active: 0,
1142
+ amount: 0,
1143
+ channel: "",
1144
+ charge: cIDCCharge,
1145
+ company: 0,
1146
+ id: "",
1147
+ operation: 0
1148
+ };
1149
+ /**
1150
+ * Common Factory Dynamic
1151
+ * */
1152
+ class FactoryDynamiCore {
1153
+ static CreateReferenceBody(client, contract, dateTime) {
1154
+ const customerInfo = {
1155
+ name: client.name,
1156
+ email: client.email,
1157
+ phone: client.phone,
1158
+ };
1159
+ const customerItems = {
1160
+ name: "Referencia Oxxo",
1161
+ unit_price: contract.financial.weeklyPayment,
1162
+ quantity: 1
1163
+ };
1164
+ const paymentMethod = {
1165
+ type: "oxxo_cash"
1166
+ };
1167
+ if (!client.dynamic_account)
1168
+ return null;
1169
+ const body = {
1170
+ id: client.id,
1171
+ data: {
1172
+ account: Number(client.dynamic_account),
1173
+ operation: 98,
1174
+ customer_info: customerInfo,
1175
+ items: customerItems,
1176
+ payment_method: paymentMethod
1177
+ }
1178
+ };
1179
+ if (dateTime != undefined)
1180
+ body.date = dateTime;
1181
+ return body;
1182
+ }
1183
+ static CreateEmptyCustomer() {
1184
+ return cIDCCustomer;
1185
+ }
1186
+ static CreateCustomerFromOClient(client, contract) {
1187
+ const o = cIDCCustomer;
1188
+ o.pii.email = client.email;
1189
+ o.pii.name = client.name;
1190
+ o.pii.curp = client.curp;
1191
+ o.pii.phone = client.phone;
1192
+ o.pii.amount = String(contract.financial.total);
1193
+ o.pii.financed = String(contract.financial.financed);
1194
+ o.pii.amount_by_period = String(contract.financial.weeklyPayment);
1195
+ o.pii.zipcode = contract.address.zip;
1196
+ o.pii.street = contract.address.street;
1197
+ o.pii.city = contract.address.city;
1198
+ o.pii.state = contract.address.state;
1199
+ o.pii.colony = contract.address.neighbor;
1200
+ o.pii.num_ext = contract.address.ext;
1201
+ return o;
1202
+ }
1203
+ static CreateDynamicCredit(client, contract, clientDynamic) {
1204
+ const properties = {
1205
+ start_date: "",
1206
+ principal_disbursed: 0,
1207
+ expected_disbursed: 0,
1208
+ amount_commission_opening: 0
1209
+ };
1210
+ const config = {
1211
+ contract: `FP-${client.name}`,
1212
+ credit_type: "Arrendamiento",
1213
+ interest_rate: 528,
1214
+ installments: 0,
1215
+ periodicity: "WEEK",
1216
+ interest_base: "ACT/ACT",
1217
+ commission_opening: 40,
1218
+ financed_amount: contract.financial.financed,
1219
+ interest_arrears: 0
1220
+ };
1221
+ if (!client.dynamic_account)
1222
+ return null;
1223
+ return {
1224
+ id: Number(client.dynamic_account),
1225
+ group: clientDynamic.group,
1226
+ company: clientDynamic.company,
1227
+ client: clientDynamic.id,
1228
+ created_at: "",
1229
+ currency: "484",
1230
+ status: "pending",
1231
+ properties: properties,
1232
+ product: 1756,
1233
+ enabled: "1",
1234
+ config: config,
1235
+ amount: 0,
1236
+ type: "liabilities",
1237
+ identifier: null,
1238
+ start_at: null
1239
+ };
1240
+ }
1241
+ static CreatePayment(contract, clientDynamic) {
1242
+ return {
1243
+ account: String(clientDynamic.id),
1244
+ amount: contract.financial.weeklyPayment,
1245
+ date: "",
1246
+ dst_account: String(clientDynamic.id),
1247
+ external_id: "",
1248
+ extras: {},
1249
+ operation: 98,
1250
+ reference: ""
1251
+ };
1252
+ }
1253
+ static getNextDateTime() {
1254
+ const now = new Date();
1255
+ const nextDateTime = new Date(now.getTime() + 1000); // Add 1 second as an example
1256
+ const year = nextDateTime.getFullYear();
1257
+ const month = String(nextDateTime.getMonth() + 1).padStart(2, '0');
1258
+ const day = String(nextDateTime.getDate()).padStart(2, '0');
1259
+ const hours = String(nextDateTime.getHours()).padStart(2, '0');
1260
+ const minutes = String(nextDateTime.getMinutes()).padStart(2, '0');
1261
+ const seconds = String(nextDateTime.getSeconds()).padStart(2, '0');
1262
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
1263
+ }
1264
+ static getIsoDate() {
1265
+ const now = new Date();
1266
+ return now.toISOString();
1267
+ }
1268
+ static FormPayment(contract, account) {
1269
+ let data = FactoryDynamiCore.CreatePayment(contract, account);
1270
+ return {
1271
+ amount: new UntypedFormControl(data.amount, [Validators.required, Validators.min(0)]),
1272
+ };
1273
+ }
1274
+ }
1275
+
1276
+ const keyUserID = "rc_uid";
1277
+ const dbVersion = 1;
1278
+ const dbName = "RavCreditDB";
1279
+ const keyPathId = "id";
1280
+ const dbAuthStore = "authStore";
1281
+ const dbUsersStore = "usersStore";
1282
+ const dbContractsStore = "contractsStore";
1283
+ const dbClientsStore = "clientsStore";
1284
+ const dbBusinessInfo = "businessInfo";
1285
+ const dbBusinessConfig = "businessConfig";
1286
+ const dbConektaClientsStore = "conektaClientsStore";
1287
+ const dbConektaReferencesStore = "conektaReferencesStore";
1288
+ const dbPassportReferencesStore = "passportReferencesStore";
1289
+ const dbDynamicReferencesStore = "dynamicReferencesStore";
1290
+ const dbDynamicAccountStore = "dynamicAccountStore";
1291
+ const dbNotificationsStore = "notificationsStore";
1292
+ const dbPaymentsStore = "paymentsStore";
1293
+ const dbIndexAuth = "iAuth";
1294
+ const dbIndexUsers = "iUsers";
1295
+ const dbIndexContracts = "iContracts";
1296
+ const dbIndexClients = "iClients";
1297
+ const dbIndexBusiness = "iBusiness";
1298
+ const dbIndexConektaClients = "iConecktaClients";
1299
+ const dbIndexConektaClientsRef = "iConecktaClientsRef";
1300
+ const dbIndexPassportClientsRef = "iPassportClientsRef";
1301
+ const dbIndexNotification = "iNotification";
1302
+ const dbIndexPayments = "iNotification";
1303
+ const dateFormat = "EEEE, dd MMM yyyy";
1304
+ const dateCompleteFormat = "EEEE, dd MMM yyyy hh:mm aaaa";
1305
+ const timeFormat = "hh:mm aaaa";
1306
+ const expiredPayment = "expiredPayment";
1307
+
1308
+ class IndexedDbService {
1309
+ indexDbStatus = false;
1310
+ iDb;
1311
+ constructor() {
1312
+ }
1313
+ async dbAuthorization() {
1314
+ // const k = this.getLocalUser()
1315
+ // if (k == null) return false
1316
+ //
1317
+ // const db = await openDB(dbName, dbVersion)
1318
+ // // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1319
+ // const auth = await db.get(dbAuthStore, k)
1320
+ // // utils auth = await store.get(k)
1321
+ // db.close()
1322
+ let auth = null;
1323
+ return auth;
1324
+ }
1325
+ async dbSignIn(store, data) {
1326
+ await this.iDb.put(store, data);
1327
+ const _data = data;
1328
+ this.setLocalStorage(keyUserID, _data.id);
1329
+ }
1330
+ setLocalStorage(k, v) {
1331
+ localStorage.setItem(k, v);
1332
+ }
1333
+ getLocalStorage(k) {
1334
+ return localStorage.getItem(k);
1335
+ }
1336
+ deleteLocalStorage(k) {
1337
+ return localStorage.removeItem(k);
1338
+ }
1339
+ getLocalUser() {
1340
+ const k = localStorage.getItem(keyUserID);
1341
+ return (k);
1342
+ }
1343
+ async getPlatformUser() {
1344
+ const k = this.getLocalStorage(keyUserID);
1345
+ if (k == null)
1346
+ return "";
1347
+ const db = await openDB(dbName, dbVersion);
1348
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1349
+ const auth = await db.get(dbAuthStore, k);
1350
+ // utils auth = await store.get(k)
1351
+ db.close();
1352
+ return auth.name != "" ? auth.name : "";
1353
+ }
1354
+ async getToken() {
1355
+ const k = this.getLocalUser();
1356
+ if (k == null)
1357
+ return "";
1358
+ const db = await openDB(dbName, dbVersion);
1359
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
1360
+ const auth = await db.get(dbAuthStore, k);
1361
+ // utils auth = await store.get(k)
1362
+ db.close();
1363
+ return auth.access_token != "" ? auth.access_token : "";
1364
+ }
1365
+ async addObject(store, data) {
1366
+ try {
1367
+ const db = await openDB(dbName, dbVersion);
1368
+ await db.put(store, data);
1369
+ return true;
1370
+ }
1371
+ catch (e) {
1372
+ return false;
1373
+ }
1374
+ }
1375
+ async patchObject(store, data) {
1376
+ try {
1377
+ const db = await openDB(dbName, dbVersion);
1378
+ const txn = db.transaction(store, "readwrite");
1379
+ const obj = txn.objectStore(store);
1380
+ // const index = obj.index(keyPathCurp)
1381
+ await obj.put(data);
1382
+ return data;
1383
+ }
1384
+ catch (e) {
1385
+ console.error(e);
1386
+ return {};
1387
+ }
1388
+ }
1389
+ async updateObjectByID(store, id, data) {
1390
+ try {
1391
+ const db = await openDB(dbName, dbVersion);
1392
+ const res = await db.get(store, id);
1393
+ if (res != undefined)
1394
+ await this.removeObject(dbClientsStore, id);
1395
+ return await this.addObject(store, data);
1396
+ }
1397
+ catch (e) {
1398
+ console.error("updateObjectByID Catch Error:", e);
1399
+ return false;
1400
+ }
1401
+ }
1402
+ async upsertObjectById(store, id, data) {
1403
+ const db = await openDB(dbName, dbVersion);
1404
+ const res = await db.get(store, id);
1405
+ if (res)
1406
+ await this.removeObject(store, id);
1407
+ return await db.add(store, data);
1408
+ }
1409
+ async removeObject(store, data) {
1410
+ const db = await openDB(dbName, dbVersion);
1411
+ return await db.delete(store, data);
1412
+ }
1413
+ async deleteObjectByID(store, id) {
1414
+ try {
1415
+ const db = await openDB(dbName, dbVersion);
1416
+ const txn = db.transaction(store, "readwrite");
1417
+ const obj = txn.objectStore(store);
1418
+ const index = obj.index(keyPathId);
1419
+ const va2 = index.openCursor(id);
1420
+ va2.then(async (cursor) => {
1421
+ while (cursor) {
1422
+ cursor.delete();
1423
+ cursor = await cursor.continue();
1424
+ }
1425
+ });
1426
+ return va2;
1427
+ }
1428
+ catch (e) {
1429
+ console.error(e);
1430
+ return {};
1431
+ }
1432
+ }
1433
+ async cleanAll(store) {
1434
+ const db = await openDB(dbName, dbVersion);
1435
+ return await db.clear(store);
1436
+ }
1437
+ async getObject(store, data) {
1438
+ if (!data)
1439
+ return data;
1440
+ const db = await openDB(dbName, dbVersion);
1441
+ return await db.get(store, data);
1442
+ }
1443
+ async addBuildByStore(store, data) {
1444
+ for (const o of data) {
1445
+ const exists = await this.getObject(store, o["id"]);
1446
+ if (!exists)
1447
+ await this.addObject(store, o);
1448
+ else
1449
+ await this.updateObject(store, o);
1450
+ }
1451
+ }
1452
+ async updateObject(store, data) {
1453
+ const db = await openDB(dbName, dbVersion);
1454
+ await db.put(store, data);
1455
+ }
1456
+ async getAllByStore(store, index) {
1457
+ const db = await openDB(dbName, dbVersion);
1458
+ return await db.getAll(store);
1459
+ }
1460
+ async getAuthUser() {
1461
+ const data = await this.getAllByStore(dbAuthStore);
1462
+ return data[0];
1463
+ }
1464
+ async getAuthName() {
1465
+ const data = await this.getAuthUser();
1466
+ return data.name;
1467
+ }
1468
+ async getAuthUsername() {
1469
+ const data = await this.getAuthUser();
1470
+ return data.username;
1471
+ }
1472
+ async saveDataLocally(contract, client, providerData) {
1473
+ try {
1474
+ await this.addObject(dbClientsStore, client);
1475
+ await this.addObject(dbContractsStore, contract);
1476
+ if (!providerData)
1477
+ return false;
1478
+ if (contract.financial.provider === eProvider.Conekta) {
1479
+ await this.addObject(dbConektaClientsStore, providerData);
1480
+ await this.addObject(dbConektaReferencesStore, providerData);
1481
+ }
1482
+ else if (contract.financial.provider === eProvider.Passport) {
1483
+ await this.addObject(dbPassportReferencesStore, providerData);
1484
+ }
1485
+ else if (contract.financial.provider === eProvider.DynamiCore) {
1486
+ await this.addObject(dbDynamicReferencesStore, providerData);
1487
+ }
1488
+ return true;
1489
+ }
1490
+ catch (e) {
1491
+ console.error(e);
1492
+ return false;
1493
+ }
1494
+ }
1495
+ /******************** MERGE **************************************/
1496
+ async getAllClientContracts() {
1497
+ const clientContract = [];
1498
+ const clients = await this.getAllByStore(dbClientsStore);
1499
+ if (clients.length == 0)
1500
+ return [];
1501
+ for (let client of clients) {
1502
+ const contract = await this.getObject(dbContractsStore, client.contract);
1503
+ const e = { ...client, ...contract };
1504
+ // preserve the id value over concat models
1505
+ e.id = client.id;
1506
+ e.status = client.status;
1507
+ clientContract.push(e);
1508
+ }
1509
+ return clientContract;
1510
+ }
1511
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1512
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, providedIn: 'root' });
1513
+ }
1514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, decorators: [{
1515
+ type: Injectable,
1516
+ args: [{
1517
+ providedIn: 'root'
1518
+ }]
1519
+ }], ctorParameters: () => [] });
1520
+
994
1521
  /*
995
1522
  * Public API Surface of ravcredit-lib
996
1523
  */
@@ -999,5 +1526,5 @@ var ePassportTypes;
999
1526
  * Generated bundle index. Do not edit.
1000
1527
  */
1001
1528
 
1002
- export { RavcreditLibComponent, RavcreditLibService, cAuthConfig, cConektaRecurrent, cNotification, cOptionsClientStatus, cOxxoRecurrentSources, cOxxorecurrentSourcesData, cPaymentDalay, cSingleOptionClientStatus, cTopic, cTyClientContract, eAuthActions, eAuthType, eClientStatus, eConektaOrderStatus, eConektaRes, eLoginStatus, eNotificationType, ePassportTypes, eProcessStatus, eRoles, eRolesSelect, snackBarConfigAction, snackBarConfigNoAction };
1529
+ export { FactoryBusiness, FactoryClient, FactoryContract, FactoryDynamiCore, IndexedDbService, RavcreditLibComponent, RavcreditLibService, cAddress, cAuthConfig, cBusinessConfig, cBusinessDeadlines, cBusinessInfo, cClient, cClientConekta, cClientContract, cClientDynamicStatus, cConektaRecurrent, cContract, 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, eProcessStatus, eProvider, eReferenceStatusRav, eRoles, eRolesSelect, expiredPayment, keyPathId, keyUserID, snackBarConfigAction, snackBarConfigNoAction, timeFormat, week };
1003
1530
  //# sourceMappingURL=ravcredit-lib.mjs.map