ravcredit-lib 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/esm2022/lib/v1/objects/oAddress.mjs +2 -0
  2. package/esm2022/lib/v1/objects/oBusiness.mjs +2 -0
  3. package/esm2022/lib/v1/objects/oClient.mjs +2 -0
  4. package/esm2022/lib/v1/objects/oConekta.mjs +85 -0
  5. package/esm2022/lib/v1/objects/oContract.mjs +2 -0
  6. package/esm2022/lib/v1/objects/oContractAll.mjs +2 -0
  7. package/esm2022/lib/v1/objects/oCustomer.mjs +18 -0
  8. package/esm2022/lib/v1/objects/oDevice.mjs +2 -0
  9. package/esm2022/lib/v1/objects/oFinancial.mjs +2 -0
  10. package/esm2022/lib/v1/objects/oGlobal.mjs +86 -0
  11. package/esm2022/lib/v1/objects/oLogIn.mjs +17 -0
  12. package/esm2022/lib/v1/objects/oNewPayment.mjs +2 -0
  13. package/esm2022/lib/v1/objects/oNotification.mjs +17 -0
  14. package/esm2022/lib/v1/objects/oPassport.mjs +7 -0
  15. package/esm2022/lib/v1/objects/oUser.mjs +2 -0
  16. package/esm2022/lib/v1/util/UtilBusiness.mjs +181 -0
  17. package/esm2022/lib/v1/util/UtilClient.mjs +221 -0
  18. package/esm2022/lib/v1/util/UtilContract.mjs +339 -0
  19. package/esm2022/lib/v1/util/UtilDynamiCore.mjs +292 -0
  20. package/esm2022/public-api.mjs +16 -2
  21. package/fesm2022/ravcredit-lib.mjs +962 -1
  22. package/fesm2022/ravcredit-lib.mjs.map +1 -1
  23. package/lib/v1/objects/oAddress.d.ts +9 -0
  24. package/lib/v1/objects/oBusiness.d.ts +101 -0
  25. package/lib/{oClient.d.ts → v1/objects/oClient.d.ts} +0 -1
  26. package/lib/v1/objects/oConekta.d.ts +305 -0
  27. package/lib/v1/objects/oContract.d.ts +23 -0
  28. package/lib/v1/objects/oContractAll.d.ts +21 -0
  29. package/lib/v1/objects/oCustomer.d.ts +17 -0
  30. package/lib/v1/objects/oDevice.d.ts +5 -0
  31. package/lib/v1/objects/oFinancial.d.ts +30 -0
  32. package/lib/v1/objects/oGlobal.d.ts +149 -0
  33. package/lib/v1/objects/oLogIn.d.ts +30 -0
  34. package/lib/v1/objects/oNewPayment.d.ts +11 -0
  35. package/lib/v1/objects/oNotification.d.ts +25 -0
  36. package/lib/v1/objects/oPassport.d.ts +55 -0
  37. package/lib/v1/objects/oUser.d.ts +25 -0
  38. package/lib/v1/util/UtilBusiness.d.ts +54 -0
  39. package/lib/v1/util/UtilClient.d.ts +34 -0
  40. package/lib/v1/util/UtilContract.d.ts +71 -0
  41. package/lib/v1/util/UtilDynamiCore.d.ts +453 -0
  42. package/package.json +1 -1
  43. package/public-api.d.ts +15 -1
  44. package/esm2022/lib/oClient.mjs +0 -2
@@ -1,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component } from '@angular/core';
3
+ import { UntypedFormControl, Validators, UntypedFormArray } from '@angular/forms';
3
4
 
4
5
  class RavcreditLibService {
5
6
  constructor() { }
@@ -30,6 +31,966 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
30
31
  ` }]
31
32
  }] });
32
33
 
34
+ var eConektaRes;
35
+ (function (eConektaRes) {
36
+ eConektaRes["CUSTOMER_CREATED"] = "customer.created";
37
+ eConektaRes["ORDER_PENDING_PAYMENT"] = "order.pending_payment";
38
+ eConektaRes["ORDER_CREATED"] = "order.created";
39
+ eConektaRes["CHARGE_CREATED"] = "charge.created";
40
+ eConektaRes["ORDER_PAID"] = "order.paid";
41
+ eConektaRes["CHARGE_PAID"] = "charge.paid";
42
+ })(eConektaRes || (eConektaRes = {}));
43
+ var eConektaOrderStatus;
44
+ (function (eConektaOrderStatus) {
45
+ eConektaOrderStatus["expired"] = "expired";
46
+ eConektaOrderStatus["paid"] = "paid";
47
+ eConektaOrderStatus["pending_payment"] = "pending_payment";
48
+ })(eConektaOrderStatus || (eConektaOrderStatus = {}));
49
+ /******************************************************* New reference constant */
50
+ const cOxxorecurrentSourcesData = {
51
+ id: "",
52
+ object: "",
53
+ type: "",
54
+ provider: "",
55
+ reference: "",
56
+ barcode: "",
57
+ barcode_url: "",
58
+ expires_at: 0,
59
+ created_at: 0,
60
+ parent_id: ""
61
+ };
62
+ const cOxxoRecurrentSources = {
63
+ object: "",
64
+ has_more: false,
65
+ total: 0,
66
+ data: []
67
+ };
68
+ const cConektaRecurrent = {
69
+ livemode: false,
70
+ name: "",
71
+ email: "",
72
+ phone: "",
73
+ id: "",
74
+ object: "",
75
+ created_at: 0,
76
+ corporate: false,
77
+ custom_id: "",
78
+ payment_sources: cOxxoRecurrentSources
79
+ };
80
+ //
81
+ // {
82
+ // data: {
83
+ // object: {
84
+ // id: '66bf1b25e341ed00158a169a',
85
+ // livemode: false,
86
+ // created_at: 1723800357,
87
+ // currency: 'MXN',
88
+ // payment_method: [Object],
89
+ // object: 'charge',
90
+ // description: 'Payment from order',
91
+ // status: 'paid',
92
+ // amount: 28125,
93
+ // paid_at: 1723800396,
94
+ // fee: 1273,
95
+ // customer_id: '',
96
+ // order_id: 'ord_2wTWbvyFgywHDvTZg'
97
+ // },
98
+ // previous_attributes: { status: 'pending_payment' }
99
+ // },
100
+ // livemode: false,
101
+ // webhook_status: 'pending',
102
+ // webhook_logs: [
103
+ // {
104
+ // id: 'webhl_2wTWcRE8ThHpvG1QQ',
105
+ // url: 'https://b1b6-2806-230-2610-b3ed-dcbe-6d32-758f-17c6.ngrok-free.app/api/v1/webhook',
106
+ // failed_attempts: 0,
107
+ // last_http_response_status: -1,
108
+ // response_data: null,
109
+ // object: 'webhook_log',
110
+ // last_attempted_at: 0
111
+ // }
112
+ // ],
113
+ // id: '66bf1b4c2973ff0001dff653',
114
+ // object: 'event',
115
+ // type: 'charge.paid',
116
+ // created_at: 1723800396
117
+ // }
118
+
119
+ //
120
+ // export interface iCustomerInfo = Pick<iCustomer, email | id | name | phone> {
121
+ //
122
+ // customer_id:string
123
+ // }
124
+ // {
125
+ // livemode: false,
126
+ // name: Vicente Mendoza,
127
+ // email: vicente.mendoza@conekta.com,
128
+ // phone: 5566982093,
129
+ // id: cus_2wHtqBNsSggaYdfXu,
130
+ // object: customer,
131
+ // created_at: 1721258796,
132
+ // corporate: false,
133
+ // custom_reference:
134
+ // }
135
+
136
+ const cClient = {
137
+ id: "",
138
+ name: "",
139
+ username: "",
140
+ email: "",
141
+ phone: "",
142
+ curp: "",
143
+ contract_temporary: "",
144
+ conekta_id: "",
145
+ userReferences: [],
146
+ status: ""
147
+ };
148
+ const cUserReference = {
149
+ name: "",
150
+ phone: "",
151
+ relationship: ""
152
+ };
153
+ const cClientConekta = {
154
+ conekta: cConektaRecurrent,
155
+ ravcredit: cClient
156
+ };
157
+ const cClientContract = {
158
+ client: cClient,
159
+ contract: cContract,
160
+ };
161
+ class FactoryClient {
162
+ static CreateClientToConektaObj(data) {
163
+ const o = {};
164
+ if (data.name && data.name.length > 0)
165
+ o.name = data.name;
166
+ if (data.username && data.name.length > 0)
167
+ o.username = data.username;
168
+ if (data.email && data.email.length > 0)
169
+ o.email = data.email;
170
+ if (data.phone && data.phone.length > 0)
171
+ o.phone = String(data.phone);
172
+ if (data.curp && data.curp.length > 0)
173
+ o.curp = data.curp;
174
+ if (data.userReferences && data.userReferences.length > 0)
175
+ o.userReferences = data.userReferences;
176
+ if (data.contract)
177
+ o.contract = data.contract;
178
+ if (data.createdAt)
179
+ o.createdAt = data.createdAt;
180
+ if (data.lastLogin)
181
+ o.lastLogin = data.lastLogin;
182
+ if (data.conekta_id)
183
+ o.conekta_id = data.conekta_id;
184
+ return o;
185
+ }
186
+ static CreateClientFromFormObj(data, client) {
187
+ const o = {
188
+ id: "",
189
+ name: data["client"][0].name,
190
+ username: data["auth"][0].username,
191
+ password: data["auth"][0].password,
192
+ email: data["client"][0].email,
193
+ phone: String(data["client"][0].phone),
194
+ curp: data["client"][0].curp,
195
+ userReferences: data["client"][0].userReferences,
196
+ status: eClientStatus.ACTIVE
197
+ };
198
+ if (client != undefined) {
199
+ if (client.dynamic_id)
200
+ o.dynamic_id = client.dynamic_id;
201
+ if (client.dynamic_account)
202
+ o.dynamic_account = client.dynamic_account;
203
+ if (client.conekta_id)
204
+ o.conekta_id = client.conekta_id;
205
+ }
206
+ return o;
207
+ }
208
+ static CreateClientConektaObj(data, finalDate) {
209
+ const sources = {
210
+ type: "oxxo_recurrent",
211
+ expires_at: finalDate
212
+ };
213
+ return {
214
+ name: data.name,
215
+ email: data.email,
216
+ phone: data.phone,
217
+ contract: data.contract_temporary,
218
+ client_id: data.id,
219
+ payment_sources: [sources]
220
+ };
221
+ }
222
+ static MapperConektaClient(client, conekta) {
223
+ const o = client;
224
+ o.name = conekta.name;
225
+ o.email = conekta.email;
226
+ o.phone = conekta.phone;
227
+ o.conekta_id = conekta.id;
228
+ return {
229
+ client: o,
230
+ contract: cContract
231
+ };
232
+ }
233
+ static MapperTypeContCli_Client(_client) {
234
+ const client = {
235
+ id: _client.id,
236
+ name: _client.name,
237
+ username: _client.username,
238
+ email: _client.email,
239
+ phone: _client.phone,
240
+ curp: _client.curp,
241
+ userReferences: _client.userReferences,
242
+ status: _client.status,
243
+ contract: _client.contract,
244
+ reference: _client.reference,
245
+ references: _client.references,
246
+ conekta_id: _client.conekta_id,
247
+ dynamic_account: _client.dynamic_account,
248
+ token: _client.token,
249
+ contract_temporary: _client.contract_temporary,
250
+ lastLogin: _client.lastLogin,
251
+ dynamic_id: _client.dynamic_id,
252
+ createdAt: _client.createdAt,
253
+ payments: _client.payments,
254
+ password: _client.password,
255
+ contractUrl: _client.contractUrl,
256
+ dynamic_ref: _client.dynamic_ref,
257
+ exists: _client.exists,
258
+ passport_id: _client.passport_id,
259
+ };
260
+ return client;
261
+ }
262
+ static MapperDynamicClient(dynamic, client, contract, clientDyn, account) {
263
+ // const o: tyClientContract = cTyClientContract
264
+ /* Client ------------------------------------------------------ */
265
+ client.username = `${dynamic.pii.name} ${dynamic.pii.motherlastname} ${dynamic.pii.lastname}`;
266
+ client.phone = dynamic.pii.phone;
267
+ client.dynamic_id = dynamic.id;
268
+ client.curp = dynamic.pii.curp;
269
+ client.email = dynamic.pii.email;
270
+ if (account)
271
+ client.dynamic_account = account.id;
272
+ /* Auth ---------------------------------------------------------- */
273
+ /* Device -------------------------------------------------------- */
274
+ contract.device.IMEI = clientDyn.pii.imei;
275
+ contract.device.device = clientDyn.pii.model;
276
+ /* Contract ------------------------------------------------------ */
277
+ contract.by = clientDyn.pii.seller_name;
278
+ if (clientDyn.pii.fotografia_del_cliente_con_el_equipo != undefined) {
279
+ const oPhoto = clientDyn.pii.fotografia_del_cliente_con_el_equipo;
280
+ if (oPhoto != "") {
281
+ const _photo = JSON.parse(oPhoto);
282
+ if (_photo)
283
+ contract.photo = _photo[0].url;
284
+ }
285
+ }
286
+ contract.address.state = dynamic.pii.state;
287
+ contract.address.city = dynamic.pii.city;
288
+ contract.address.street = dynamic.pii.street;
289
+ contract.address.ext = dynamic.pii.num_ext;
290
+ contract.address.zip = dynamic.pii.zipcode;
291
+ contract.address.neighbor = dynamic.pii.colony;
292
+ /* Financial ------------------------------------------------------ */
293
+ contract.dynamicAccount = Number(account?.id);
294
+ if (account?.config.installments) {
295
+ contract.financial.deadlines = {
296
+ weeks: account.config.installments,
297
+ interest: 0
298
+ };
299
+ }
300
+ if (account?.properties.expected_disbursed)
301
+ contract.financial.total = account?.properties.expected_disbursed;
302
+ if (account?.properties.principal_disbursed)
303
+ contract.financial.financed = account?.properties.principal_disbursed;
304
+ if (account?.properties.amount_commission_opening) {
305
+ contract.financial.initial = account?.properties.amount_commission_opening;
306
+ contract.financial.amount_commission_opening = account?.properties.amount_commission_opening;
307
+ }
308
+ contract.financial.interest_rate = Number(clientDyn.pii.interest_rate);
309
+ contract.financial.interest_arrears = account?.config.interest_arrears;
310
+ contract.financial.commission_opening = account?.config.commission_opening;
311
+ contract.financial.credit_type = account?.config.credit_type;
312
+ contract.financial.principal_disbursed = account?.properties.principal_disbursed;
313
+ contract.financial.expected_disbursed = account?.properties.expected_disbursed;
314
+ contract.financial.weeklyPayment = Number(clientDyn.pii.amount_by_period);
315
+ return {
316
+ client: client,
317
+ contract: contract,
318
+ };
319
+ }
320
+ static MapperFinancialContract(contract, account) {
321
+ contract.dynamicAccount = Number(account.id);
322
+ if (account.config.installments) {
323
+ contract.financial.deadlines = {
324
+ weeks: account.config.installments,
325
+ interest: 0
326
+ };
327
+ }
328
+ const total = account.config.financed_amount != undefined ? account.config.financed_amount : 0;
329
+ if (total > 0)
330
+ contract.financial.total = total;
331
+ // if (account.properties.expected_disbursed)
332
+ const expected_disbursed = account.properties.expected_disbursed != undefined ? account.properties.expected_disbursed : 0;
333
+ if (expected_disbursed > 0)
334
+ contract.financial.total = expected_disbursed;
335
+ contract.financial.expected_disbursed = expected_disbursed;
336
+ contract.financial.interest_rate = account.config.interest_rate;
337
+ contract.financial.interest_arrears = account.config.interest_arrears;
338
+ // if (account.properties.principal_disbursed)
339
+ if (account.properties.principal_disbursed > 0)
340
+ contract.financial.financed = account.properties.principal_disbursed;
341
+ contract.financial.principal_disbursed = account.properties.principal_disbursed;
342
+ const amount_commission_opening = account.properties.amount_commission_opening != undefined ? account.properties.amount_commission_opening : 0;
343
+ if (amount_commission_opening > 0)
344
+ contract.financial.initial = amount_commission_opening;
345
+ contract.financial.amount_commission_opening = amount_commission_opening;
346
+ contract.financial.interest_arrears = account.config.interest_arrears;
347
+ contract.financial.commission_opening = account.config.commission_opening;
348
+ contract.financial.credit_type = account.config.credit_type;
349
+ contract.financial.clabe = String(account.properties.clabe);
350
+ return contract.financial;
351
+ }
352
+ }
353
+
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
+ const cSchedule = {
366
+ day: "",
367
+ open: 0,
368
+ close: 0,
369
+ };
370
+ const cEmptyDay = {
371
+ close: 0, open: 0, day: ""
372
+ };
373
+ const week = [
374
+ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
375
+ ];
376
+ const cDefinedSchedule = [
377
+ { close: 0, open: 0, day: "monday" },
378
+ { close: 0, open: 0, day: "tuesday" },
379
+ { close: 0, open: 0, day: "wednesday" },
380
+ { close: 0, open: 0, day: "thursday" },
381
+ { close: 0, open: 0, day: "friday" },
382
+ { close: 0, open: 0, day: "saturday" },
383
+ { close: 0, open: 0, day: "sunday" },
384
+ ];
385
+ const cBusinessInfo = {
386
+ version: "v2024",
387
+ name: "",
388
+ address: cAddress$1,
389
+ phones: [],
390
+ email: "",
391
+ };
392
+ const cBusinessDeadlines = {
393
+ weeks: 0,
394
+ interest: 0
395
+ };
396
+ const cBusinessConfig = {
397
+ version: "",
398
+ apiVersion: "",
399
+ adminVersion: "",
400
+ mobileVersion: "",
401
+ mobileVersionPrev: "",
402
+ deadlines: [],
403
+ downloadsClient: false,
404
+ passportPaymentReference: false,
405
+ conektaPaymentReference: false,
406
+ conektaPaymentLink: false,
407
+ dynamicPaymentReference: false,
408
+ 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"
409
+ };
410
+ class FactoryBusiness {
411
+ static FormBusinessInfo(info) {
412
+ let data = cBusinessInfo;
413
+ if (info)
414
+ data = info;
415
+ if (!info?.address)
416
+ data.address = cAddress$1;
417
+ return {
418
+ name: new UntypedFormControl(data.name, Validators.required),
419
+ email: new UntypedFormControl(data.email, [Validators.required, Validators.email]),
420
+ desc: new UntypedFormControl(data.desc, [Validators.required, Validators.email]),
421
+ street: new UntypedFormControl(data.address.street, Validators.required),
422
+ neighbor: new UntypedFormControl(data.address.neighbor, Validators.required),
423
+ cp: new UntypedFormControl(data.address.zip, Validators.required),
424
+ ext: new UntypedFormControl(data.address.ext, Validators.required),
425
+ int: new UntypedFormControl(data.address.int),
426
+ city: new UntypedFormControl(data.address.city, Validators.required),
427
+ state: new UntypedFormControl(data.address.state, Validators.required),
428
+ phones: new UntypedFormControl(data.phones),
429
+ mondayOpen: new UntypedFormControl(data.schedule?.monday.open),
430
+ mondayClose: new UntypedFormControl(data.schedule?.monday.close),
431
+ tuesdayOpen: new UntypedFormControl(data.schedule?.tuesday.open),
432
+ tuesdayClose: new UntypedFormControl(data.schedule?.tuesday.close),
433
+ wednesdayOpen: new UntypedFormControl(data.schedule?.wednesday.open),
434
+ wednesdayClose: new UntypedFormControl(data.schedule?.wednesday.close),
435
+ thursdayOpen: new UntypedFormControl(data.schedule?.thursday.open),
436
+ thursdayClose: new UntypedFormControl(data.schedule?.thursday.close),
437
+ fridayOpen: new UntypedFormControl(data.schedule?.friday.open),
438
+ fridayClose: new UntypedFormControl(data.schedule?.friday.close),
439
+ saturdayOpen: new UntypedFormControl(data.schedule?.saturday.open),
440
+ saturdayClose: new UntypedFormControl(data.schedule?.saturday.close),
441
+ sundayOpen: new UntypedFormControl(data.schedule?.sunday.open),
442
+ sundayClose: new UntypedFormControl(data.schedule?.sunday.close),
443
+ };
444
+ }
445
+ static CreateBusinessInfoObj(data) {
446
+ const address = cAddress$1;
447
+ const schedule = {
448
+ monday: {},
449
+ tuesday: {},
450
+ wednesday: {},
451
+ thursday: {},
452
+ friday: {},
453
+ saturday: {},
454
+ sunday: {}
455
+ };
456
+ if (data.street)
457
+ address.street = data.street;
458
+ if (data.state)
459
+ address.state = data.state;
460
+ if (data.neighbor)
461
+ address.neighbor = data.neighbor;
462
+ if (data.city)
463
+ address.city = data.city;
464
+ if (data.ext)
465
+ address.ext = data.ext;
466
+ if (data.int)
467
+ address.int = data.int;
468
+ if (data.cp)
469
+ address.zip = data.cp;
470
+ if (data.mondayOpen)
471
+ schedule.monday.open = data.mondayOpen;
472
+ if (data.mondayClose)
473
+ schedule.monday.close = data.mondayClose;
474
+ if (data.tuesdayOpen)
475
+ schedule.tuesday.open = data.tuesdayOpen;
476
+ if (data.tuesdayClose)
477
+ schedule.tuesday.close = data.tuesdayClose;
478
+ if (data.wednesdayOpen)
479
+ schedule.wednesday.open = data.wednesdayOpen;
480
+ if (data.wednesdayClose)
481
+ schedule.wednesday.close = data.wednesdayClose;
482
+ if (data.thursdayOpen)
483
+ schedule.thursday.open = data.thursdayOpen;
484
+ if (data.thursdayClose)
485
+ schedule.thursday.close = data.thursdayClose;
486
+ if (data.fridayOpen)
487
+ schedule.friday.open = data.fridayOpen;
488
+ if (data.fridayClose)
489
+ schedule.friday.close = data.fridayClose;
490
+ if (data.saturdayOpen)
491
+ schedule.saturday.open = data.saturdayOpen;
492
+ if (data.saturdayClose)
493
+ schedule.saturday.close = data.saturdayClose;
494
+ if (data.sundayOpen)
495
+ schedule.sunday.open = data.sundayOpen;
496
+ if (data.sundayClose)
497
+ schedule.sunday.close = data.sundayClose;
498
+ const info = {
499
+ version: "v2024",
500
+ name: data.name ? data.name : "",
501
+ address: address,
502
+ phones: data.phones ? data.phones : [],
503
+ email: data.email ? data.email : "",
504
+ schedule: schedule,
505
+ desc: data.desc ? data.desc : ""
506
+ };
507
+ return info;
508
+ }
509
+ static FormDeadlineConfig(data) {
510
+ // if (!data) data = cBusinessDeadlines
511
+ return {
512
+ weeks: new UntypedFormControl(data.weeks),
513
+ interest: new UntypedFormControl(data.interest),
514
+ };
515
+ }
516
+ static FormBusinessConfig(config) {
517
+ let data = cBusinessConfig;
518
+ if (config)
519
+ data = config;
520
+ return {
521
+ downloadsClient: new UntypedFormControl(data.downloadsClient),
522
+ passportPaymentReference: new UntypedFormControl(data.passportPaymentReference),
523
+ conektaPaymentReference: new UntypedFormControl(data.conektaPaymentReference),
524
+ conektaPaymentLink: new UntypedFormControl(data.conektaPaymentLink),
525
+ dynamicPaymentReference: new UntypedFormControl(data.dynamicPaymentReference),
526
+ deadlines: new UntypedFormArray([])
527
+ };
528
+ }
529
+ static testBusiness(message) {
530
+ return `Message ${message}`;
531
+ }
532
+ }
533
+
534
+ var eProvider;
535
+ (function (eProvider) {
536
+ eProvider["none"] = "";
537
+ eProvider["Conekta"] = "Conekta";
538
+ eProvider["Passport"] = "Passport";
539
+ eProvider["DynamiCore"] = "DynamiCore";
540
+ })(eProvider || (eProvider = {}));
541
+ // export type ProgressTaskStatus = TaskState | "uploading" | "idle" | "generating" | "unauthorized"
542
+ const cDevice = {
543
+ device: "",
544
+ IMEI: ""
545
+ };
546
+ const cFinancial = {
547
+ total: 0,
548
+ initial: 0,
549
+ deadlines: cBusinessDeadlines,
550
+ initDate: 0,
551
+ weeklyPayment: 0,
552
+ pendingOf: [],
553
+ progress: [],
554
+ interest: 0,
555
+ provider: eProvider.DynamiCore,
556
+ financed: 0,
557
+ nextPayment: 0,
558
+ amount_commission_opening: 0,
559
+ principal_disbursed: 0,
560
+ expected_disbursed: 0, // ---------
561
+ credit_type: 'Arrendamiento',
562
+ interest_rate: 0,
563
+ commission_opening: 0,
564
+ interest_arrears: 0,
565
+ };
566
+ const cAddress = {
567
+ street: "",
568
+ city: "",
569
+ neighbor: "",
570
+ zip: "",
571
+ ext: "",
572
+ int: "",
573
+ state: ""
574
+ };
575
+ const cContract = {
576
+ id: "",
577
+ client: "",
578
+ address: cAddress,
579
+ device: cDevice,
580
+ financial: cFinancial,
581
+ by: "",
582
+ active: true
583
+ };
584
+ class FactoryContract {
585
+ static FormClient(client) {
586
+ let data = cClient;
587
+ if (client)
588
+ data = client;
589
+ return {
590
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
591
+ email: new UntypedFormControl(data.username, [Validators.required, Validators.email]),
592
+ phone: new UntypedFormControl(data.phone, [Validators.required, Validators.min(10)]),
593
+ curp: new UntypedFormControl(data.curp, [Validators.required, Validators.minLength(16)]),
594
+ userReferences: new UntypedFormArray([])
595
+ };
596
+ }
597
+ static CreateUserReferenceFormObj(user) {
598
+ let data = cUserReference;
599
+ if (user.name != "")
600
+ data = user;
601
+ return {
602
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
603
+ phone: new UntypedFormControl(data.phone, [Validators.required]),
604
+ relationship: new UntypedFormControl(data.relationship, [Validators.required]),
605
+ };
606
+ }
607
+ static FormAddress(address) {
608
+ let data = cAddress;
609
+ if (address)
610
+ data = address;
611
+ return {
612
+ street: new UntypedFormControl(data.street, Validators.required),
613
+ neighbor: new UntypedFormControl(data.neighbor, Validators.required),
614
+ cp: new UntypedFormControl(data.zip, Validators.required),
615
+ ext: new UntypedFormControl(data.ext, Validators.required),
616
+ int: new UntypedFormControl(data.int),
617
+ city: new UntypedFormControl(data.city, Validators.required),
618
+ state: new UntypedFormControl(data.state, Validators.required),
619
+ };
620
+ }
621
+ static FormDevice(device) {
622
+ let data = cDevice;
623
+ if (device)
624
+ data = device;
625
+ return {
626
+ model: new UntypedFormControl(data.device, Validators.required),
627
+ IMEI: new UntypedFormControl(data.IMEI, Validators.required),
628
+ ID: new UntypedFormControl(data.id),
629
+ };
630
+ }
631
+ static FormFinancial(financial) {
632
+ let data = cFinancial;
633
+ if (financial)
634
+ data = financial;
635
+ data.credit_type = "Arrendamiento";
636
+ // data.deadlines.weeks = cBusinessDeadlines
637
+ return {
638
+ total: new UntypedFormControl(data.total, [Validators.required, Validators.min(1)]),
639
+ initial: new UntypedFormControl(data.initial, [Validators.required]),
640
+ financed: new UntypedFormControl(data.financed, Validators.min(1)),
641
+ weeklyPayment: new UntypedFormControl(data.weeklyPayment, [Validators.required, Validators.min(1)]),
642
+ deadlines: new UntypedFormControl(data.deadlines, [Validators.required]),
643
+ initDate: new UntypedFormControl(data.initDate),
644
+ provider: new UntypedFormControl(data.provider),
645
+ credit_type: new UntypedFormControl(data.credit_type ? data.credit_type : 0),
646
+ interest_rate: new UntypedFormControl(data.interest_rate ? data.interest_rate : 0), // interes credit dynamic
647
+ commission_opening: new UntypedFormControl(data.commission_opening ? data.commission_opening : 0),
648
+ interest_arrears: new UntypedFormControl(data.interest_arrears ? data.interest_arrears : 0), // intereses moratorios dynamic
649
+ amount_commission_opening: new UntypedFormControl(data.amount_commission_opening), // comision por apertura dynamic
650
+ principal_disbursed: new UntypedFormControl(data.principal_disbursed),
651
+ expected_disbursed: new UntypedFormControl(data.expected_disbursed)
652
+ };
653
+ }
654
+ static CreateContractFromFormObj(data, finalPay) {
655
+ const date = new Date();
656
+ const device = {
657
+ device: data["device"][0].model,
658
+ id: data["device"][0].ID,
659
+ IMEI: data["device"][0].IMEI
660
+ };
661
+ const address = {
662
+ street: data["address"][0].street,
663
+ city: data["address"][0].city,
664
+ neighbor: data["address"][0].neighbor,
665
+ zip: data["address"][0].cp,
666
+ ext: data["address"][0].ext,
667
+ int: data["address"][0].int,
668
+ state: data["address"][0].state
669
+ };
670
+ const financial = {
671
+ total: Number(data["financial"][0].total),
672
+ initial: data["financial"][0].initial,
673
+ deadlines: data["financial"][0].deadlines,
674
+ progress: [],
675
+ pendingOf: [],
676
+ weeklyPayment: data["financial"][0].weeklyPayment,
677
+ interest: data["financial"][0].interest_rate,
678
+ finalDate: date.getTime() + (data["financial"][0].deadlines.weeks * (604800 * 1000)),
679
+ initDate: date.getDate(),
680
+ dayCut: date.getDate(),
681
+ provider: data["financial"][0].provider,
682
+ finalPayment: finalPay,
683
+ financed: data["financial"][0].financed,
684
+ nextPayment: data["financial"][0].nextPayment
685
+ };
686
+ if (data["financial"][0].provider == eProvider.DynamiCore) {
687
+ financial.initial = data["financial"][0].amount_commission_opening ? Number(data["financial"][0].amount_commission_opening) : 0;
688
+ financial.expected_disbursed = data["financial"][0].expected_disbursed ? Number(data["financial"][0].expected_disbursed) : 0;
689
+ financial.principal_disbursed = data["financial"][0].principal_disbursed ? Number(data["financial"][0].principal_disbursed) : 0;
690
+ financial.interest_arrears = data["financial"][0].interest_rate ? Number(data["financial"][0].interest_rate) : 0;
691
+ financial.commission_opening = data["financial"][0].commission_opening ? Number(data["financial"][0].commission_opening) : 0;
692
+ financial.credit_type = data["financial"][0].credit_type ? data["financial"][0].credit_type : "";
693
+ financial.clabe = data["financial"][0].clabe ? data["financial"][0].clabe : "";
694
+ }
695
+ if (data["financial"][0].amount_commission_opening != undefined) {
696
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
697
+ financial.initial = Number(data["financial"][0].amount_commission_opening);
698
+ else
699
+ financial.initial = Number(data["financial"][0].initial);
700
+ }
701
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
702
+ financial.amount_commission_opening = Number(data["financial"][0].amount_commission_opening);
703
+ else
704
+ financial.amount_commission_opening = financial.initial;
705
+ if (financial.nextPayment == undefined)
706
+ financial.nextPayment = 0;
707
+ const contract = {
708
+ id: "",
709
+ client: "",
710
+ address: address,
711
+ device: device,
712
+ financial: financial,
713
+ by: "",
714
+ active: true,
715
+ lastPayment: date.getTime(),
716
+ createdAt: date.getTime()
717
+ };
718
+ return contract;
719
+ }
720
+ static CreateContractToConektaObj(data, monthlyPay, finalPay) {
721
+ const o = {};
722
+ const device = {
723
+ device: data.device.device,
724
+ id: data.device.id,
725
+ IMEI: data.device.IMEI
726
+ };
727
+ const address = {
728
+ street: data.address.street,
729
+ city: data.address.city,
730
+ neighbor: data.address.neighbor,
731
+ zip: data.address.zip,
732
+ ext: data.address.ext,
733
+ int: data.address.int,
734
+ state: data.address.state
735
+ };
736
+ const financial = {
737
+ total: data.financial.total,
738
+ initial: data.financial.initial,
739
+ deadlines: data.financial.deadlines,
740
+ progress: data.financial.progress,
741
+ pendingOf: data.financial.pendingOf,
742
+ weeklyPayment: data.financial.weeklyPayment,
743
+ interest: data.financial.interest,
744
+ finalDate: data.financial.finalDate,
745
+ initDate: data.financial.initDate,
746
+ dayCut: data.financial.dayCut,
747
+ provider: data.financial.provider,
748
+ finalPayment: data.financial.finalPayment,
749
+ financed: data.financial.financed,
750
+ nextPayment: data.financial.nextPayment
751
+ };
752
+ const contract = {
753
+ id: "",
754
+ client: "",
755
+ address: address,
756
+ device: device,
757
+ financial: financial,
758
+ by: "",
759
+ active: true
760
+ };
761
+ return contract;
762
+ }
763
+ static CreateAuthForm(username, curp) {
764
+ const password = this.createPassword(curp);
765
+ return {
766
+ username: new UntypedFormControl(username, Validators.required),
767
+ password: new UntypedFormControl(password, Validators.required),
768
+ };
769
+ }
770
+ static createPassword(curp) {
771
+ const _curp = curp.split("");
772
+ let password = "";
773
+ const limit = 7;
774
+ if (_curp.length < 16)
775
+ return "";
776
+ password += _curp[0].toLowerCase();
777
+ for (let i = 1; i <= limit; i++)
778
+ password += _curp[i].toUpperCase();
779
+ password += `*`;
780
+ return password;
781
+ }
782
+ static MapperTypeContCli_Contract(_contract) {
783
+ const contract = {
784
+ id: _contract.contract,
785
+ client: _contract.client,
786
+ address: _contract.address,
787
+ device: _contract.device,
788
+ financial: _contract.financial,
789
+ by: _contract.by,
790
+ active: _contract.active,
791
+ lastPayment: _contract.lastPayment,
792
+ createdAt: _contract.createdAt,
793
+ dynamicAccount: _contract.dynamicAccount,
794
+ };
795
+ return contract;
796
+ }
797
+ static MapperSyncContractDynamic(base, account) {
798
+ let nContract = base;
799
+ let _financial = base.financial;
800
+ let _device = base.device;
801
+ const financial = {
802
+ total: _financial.total,
803
+ initial: account.properties.amount_commission_opening ? account.properties.amount_commission_opening : _financial.initial,
804
+ deadlines: _financial.deadlines,
805
+ progress: _financial.progress ? _financial.progress : [],
806
+ pendingOf: _financial.pendingOf ? _financial.pendingOf : [],
807
+ weeklyPayment: _financial.weeklyPayment,
808
+ interest: _financial.interest,
809
+ finalDate: _financial.finalDate,
810
+ initDate: _financial.initDate,
811
+ dayCut: _financial.dayCut,
812
+ provider: _financial.provider,
813
+ finalPayment: _financial.finalPayment,
814
+ financed: _financial.financed,
815
+ nextPayment: _financial.nextPayment ? _financial.nextPayment : 0,
816
+ amount_commission_opening: account.properties.amount_commission_opening,
817
+ expected_disbursed: account.properties.expected_disbursed ?
818
+ Number(account.properties.expected_disbursed) :
819
+ Number(_financial.expected_disbursed),
820
+ principal_disbursed: account.properties.principal_disbursed ?
821
+ account.properties.principal_disbursed :
822
+ _financial.principal_disbursed,
823
+ commission_opening: account.config.commission_opening ?
824
+ Number(account.config.commission_opening) :
825
+ Number(_financial.commission_opening),
826
+ credit_type: account.config.credit_type ? account.config.credit_type : _financial.credit_type,
827
+ clabe: String(account.properties.clabe ? account.properties.clabe : _financial.clabe)
828
+ };
829
+ const interestArrears = account.config.interest_arrears;
830
+ const prevInterestArrears = _financial.interest_arrears;
831
+ if (interestArrears != undefined) {
832
+ financial.interest_arrears = interestArrears;
833
+ }
834
+ else if (prevInterestArrears != undefined) {
835
+ financial.interest_arrears = prevInterestArrears;
836
+ }
837
+ else {
838
+ financial.interest_arrears = 0;
839
+ }
840
+ const interest = account.config.interest_rate;
841
+ const prevInterest = _financial.interest;
842
+ if (interest != undefined) {
843
+ financial.interest = interest;
844
+ }
845
+ else if (prevInterest != undefined) {
846
+ financial.interest = prevInterest;
847
+ }
848
+ else {
849
+ financial.interest = 0;
850
+ }
851
+ if (account.properties.amount_commission_opening != undefined) {
852
+ if (Number(account.properties.amount_commission_opening) > 0) {
853
+ financial.initial = Number(account.properties.amount_commission_opening);
854
+ financial.amount_commission_opening = Number(account.properties.amount_commission_opening);
855
+ }
856
+ else {
857
+ financial.initial = Number(_financial.initial);
858
+ financial.amount_commission_opening = financial.initial;
859
+ }
860
+ }
861
+ const seller = account.properties.seller_name;
862
+ nContract.by = seller != null ? seller : "";
863
+ nContract.device.id = _device.id ? _device.id : "";
864
+ nContract.financial = financial;
865
+ return nContract;
866
+ }
867
+ }
868
+
869
+ var eRoles;
870
+ (function (eRoles) {
871
+ eRoles["Administrator"] = "Administrator";
872
+ eRoles["Seller"] = "Seller";
873
+ eRoles["Consultant"] = "Consultant";
874
+ })(eRoles || (eRoles = {}));
875
+ var eProcessStatus;
876
+ (function (eProcessStatus) {
877
+ eProcessStatus["IDLE"] = "IDLE";
878
+ eProcessStatus["ERROR"] = "ERROR";
879
+ eProcessStatus["CANCELED"] = "CANCELED";
880
+ eProcessStatus["COMPLETE"] = "COMPLETE";
881
+ eProcessStatus["PROCESSING"] = "PROCESSING";
882
+ eProcessStatus["WAITING"] = "WAITING";
883
+ })(eProcessStatus || (eProcessStatus = {}));
884
+ var eLoginStatus;
885
+ (function (eLoginStatus) {
886
+ eLoginStatus["IDLE"] = "IDLE";
887
+ eLoginStatus["ERROR"] = "ERROR";
888
+ eLoginStatus["AUTHORIZED"] = "AUTHORIZED";
889
+ eLoginStatus["CHECKING"] = "CHECKING";
890
+ eLoginStatus["NOAUTHORIZED"] = "NOAUTHORIZED";
891
+ eLoginStatus["NOTFOUND"] = "NOTFOUND";
892
+ eLoginStatus["ERRORPASSWORD"] = "ERRORPASSWORD";
893
+ })(eLoginStatus || (eLoginStatus = {}));
894
+ var eClientStatus;
895
+ (function (eClientStatus) {
896
+ eClientStatus["ACTIVE"] = "active";
897
+ eClientStatus["COMPLETED"] = "completed";
898
+ eClientStatus["PAUSED"] = "paused";
899
+ eClientStatus["CANCELED"] = "canceled";
900
+ eClientStatus["LATE"] = "late";
901
+ })(eClientStatus || (eClientStatus = {}));
902
+ const cSingleOptionClientStatus = {
903
+ viewValue: "",
904
+ value: ""
905
+ };
906
+ const cOptionsClientStatus = [
907
+ {
908
+ value: eClientStatus.ACTIVE,
909
+ viewValue: "Activar"
910
+ }, {
911
+ value: eClientStatus.COMPLETED,
912
+ viewValue: "Completar"
913
+ }, {
914
+ value: eClientStatus.PAUSED,
915
+ viewValue: "Pausar"
916
+ }, {
917
+ value: eClientStatus.LATE,
918
+ viewValue: "Marcar con atraso"
919
+ }, {
920
+ value: eClientStatus.CANCELED,
921
+ viewValue: "Cancelar"
922
+ }
923
+ ];
924
+ const eRolesSelect = [
925
+ {
926
+ value: eRoles.Administrator,
927
+ viewValue: eRoles.Administrator
928
+ },
929
+ {
930
+ value: eRoles.Consultant,
931
+ viewValue: eRoles.Consultant
932
+ },
933
+ {
934
+ value: eRoles.Seller,
935
+ viewValue: eRoles.Seller
936
+ },
937
+ ];
938
+ const cPaymentDalay = {
939
+ today: 0,
940
+ nextPayment: 0,
941
+ daysDelay: 0,
942
+ late: false,
943
+ };
944
+ const snackBarConfigAction = {
945
+ horizontalPosition: "start"
946
+ };
947
+ const snackBarConfigNoAction = {
948
+ duration: 4000,
949
+ horizontalPosition: "start"
950
+ };
951
+ const cTyClientContract = { ...cClient, ...cContract };
952
+
953
+ var eAuthActions;
954
+ (function (eAuthActions) {
955
+ eAuthActions["delete"] = "delete";
956
+ eAuthActions["auth"] = "auth";
957
+ })(eAuthActions || (eAuthActions = {}));
958
+ var eAuthType;
959
+ (function (eAuthType) {
960
+ eAuthType["auth"] = "auth";
961
+ eAuthType["login"] = "login";
962
+ eAuthType["idle"] = "";
963
+ })(eAuthType || (eAuthType = {}));
964
+ const cAuthConfig = {
965
+ title: "",
966
+ desc: "",
967
+ data: true,
968
+ };
969
+
970
+ const cTopic = "RavCreditClients";
971
+ var eNotificationType;
972
+ (function (eNotificationType) {
973
+ eNotificationType["GLOBAL"] = "global";
974
+ eNotificationType["USER"] = "user";
975
+ eNotificationType["PAYMENT"] = "payment";
976
+ })(eNotificationType || (eNotificationType = {}));
977
+ const cNotification = {
978
+ notification: {
979
+ title: "",
980
+ body: ""
981
+ },
982
+ data: {
983
+ route: ""
984
+ }
985
+ };
986
+
987
+ var ePassportTypes;
988
+ (function (ePassportTypes) {
989
+ ePassportTypes["CREATE"] = "create_references";
990
+ ePassportTypes["SEND"] = "send_references";
991
+ })(ePassportTypes || (ePassportTypes = {}));
992
+ /** ******************************** */
993
+
33
994
  /*
34
995
  * Public API Surface of ravcredit-lib
35
996
  */
@@ -38,5 +999,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
38
999
  * Generated bundle index. Do not edit.
39
1000
  */
40
1001
 
41
- export { RavcreditLibComponent, RavcreditLibService };
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 };
42
1003
  //# sourceMappingURL=ravcredit-lib.mjs.map