ravcredit-lib 0.0.7 → 0.0.9

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/ng-package.json +7 -0
  2. package/package.json +13 -24
  3. package/src/lib/ravcredit-lib.component.spec.ts +23 -0
  4. package/src/lib/ravcredit-lib.component.ts +16 -0
  5. package/src/lib/ravcredit-lib.service.spec.ts +16 -0
  6. package/src/lib/ravcredit-lib.service.ts +9 -0
  7. package/src/lib/v1/const/constants.ts +35 -0
  8. package/src/lib/v1/dto/AddressDto.ts +27 -0
  9. package/src/lib/v1/dto/BusinessDeadlineDto.ts +9 -0
  10. package/src/lib/v1/dto/ConektaDto.ts +386 -0
  11. package/src/lib/v1/dto/ContractDto.ts +46 -0
  12. package/src/lib/v1/dto/CustomerDto.ts +47 -0
  13. package/src/lib/v1/dto/DeviceDto.ts +13 -0
  14. package/src/lib/v1/dto/DynamiCoreDto.ts +1017 -0
  15. package/src/lib/v1/dto/FinancialDto.ts +156 -0
  16. package/src/lib/v1/dto/PassportDto.ts +143 -0
  17. package/src/lib/v1/dto/PayLinkResDto.ts +144 -0
  18. package/src/lib/v1/dto/PayOrderResAlternaDto.ts +348 -0
  19. package/src/lib/v1/dto/PayOrderResOxxoDto.ts +254 -0
  20. package/src/lib/v1/dto/PaymentLinkDto.ts +161 -0
  21. package/src/lib/v1/dto/ScheduleDto.ts +17 -0
  22. package/src/lib/v1/dto/UserDto.ts +27 -0
  23. package/src/lib/v1/dto/WeekScheduleDTO.ts +46 -0
  24. package/src/lib/v1/idb/idb.service.spec.ts +16 -0
  25. package/src/lib/v1/idb/indexed-db.service.ts +396 -0
  26. package/src/lib/v1/objects/oAddress.ts +19 -0
  27. package/src/lib/v1/objects/oBusiness.ts +112 -0
  28. package/src/lib/v1/objects/oClient.ts +46 -0
  29. package/src/lib/v1/objects/oConekta.ts +408 -0
  30. package/src/lib/v1/objects/oContract.ts +30 -0
  31. package/src/lib/v1/objects/oContractAll.ts +38 -0
  32. package/src/lib/v1/objects/oCustomer.ts +36 -0
  33. package/src/lib/v1/objects/oDevice.ts +5 -0
  34. package/src/lib/v1/objects/oFinancial.ts +32 -0
  35. package/src/lib/v1/objects/oGlobal.ts +186 -0
  36. package/src/lib/v1/objects/oLogIn.ts +43 -0
  37. package/src/lib/v1/objects/oNewPayment.ts +18 -0
  38. package/src/lib/v1/objects/oNotification.ts +34 -0
  39. package/src/lib/v1/objects/oPassport.ts +65 -0
  40. package/src/lib/v1/objects/oUser.ts +35 -0
  41. package/src/lib/v1/objects/oVerification.ts +48 -0
  42. package/src/lib/v1/util/UtilBusiness.ts +186 -0
  43. package/src/lib/v1/util/UtilClient.ts +285 -0
  44. package/src/lib/v1/util/UtilConekta.ts +97 -0
  45. package/src/lib/v1/util/UtilContract.ts +386 -0
  46. package/src/lib/v1/util/UtilDashboard.ts +19 -0
  47. package/src/lib/v1/util/UtilDynamiCore.ts +752 -0
  48. package/src/lib/v1/util/UtilNotification.ts +46 -0
  49. package/src/lib/v1/util/UtilPassport.ts +32 -0
  50. package/src/lib/v1/util/UtilPayment.ts +22 -0
  51. package/src/lib/v1/util/UtilTime.ts +181 -0
  52. package/src/lib/v1/util/UtilsHttp.ts +11 -0
  53. package/src/lib/v2/const/constants.ts +38 -0
  54. package/src/lib/v2/messaging/messaging.ts +10 -0
  55. package/src/public-api.ts +36 -0
  56. package/tsconfig.lib.json +15 -0
  57. package/tsconfig.lib.prod.json +11 -0
  58. package/tsconfig.spec.json +15 -0
  59. package/fesm2022/ravcredit-lib.mjs +0 -1982
  60. package/fesm2022/ravcredit-lib.mjs.map +0 -1
  61. package/index.d.ts +0 -1601
@@ -0,0 +1,386 @@
1
+ import {UntypedFormArray, UntypedFormControl, Validators} from "@angular/forms";
2
+ import {cClient, cUserReference} from "./UtilClient";
3
+ // import {TaskState} from "firebase/storage";
4
+ import {cBusinessDeadlines} from "./UtilBusiness";
5
+ import {IDCAccount} from "./UtilDynamiCore";
6
+ import {oDevice} from '../objects/oDevice';
7
+ import {oFinancial} from '../objects/oFinancial';
8
+ import {cAddress, oAddress} from '../objects/oAddress';
9
+ import {oContract} from '../objects/oContract';
10
+ import {oClient, oUserReference} from '../objects/oClient';
11
+ import {tyClientContract} from '../objects/oGlobal';
12
+
13
+ export enum eProvider {
14
+ none = "",
15
+ Conekta = "Conekta",
16
+ Passport = "Passport",
17
+ DynamiCore = "DynamiCore",
18
+ }
19
+
20
+ // export type ProgressTaskStatus = TaskState | "uploading" | "idle" | "generating" | "unauthorized"
21
+
22
+ export const cDevice: oDevice = {
23
+ device: "",
24
+ IMEI: ""
25
+ }
26
+
27
+ export const cFinancial: oFinancial = {
28
+ total: 0,
29
+ initial: 0,
30
+ deadlines: cBusinessDeadlines,
31
+ initDate: 0,
32
+ weeklyPayment: 0,
33
+ pendingOf: [],
34
+ progress: [],
35
+ interest: 0,
36
+ provider: eProvider.DynamiCore,
37
+ financed: 0,
38
+ nextPayment: 0,
39
+ amount_commission_opening: 0,
40
+ principal_disbursed: 0,
41
+ expected_disbursed: 0, // ---------
42
+ credit_type: 'Arrendamiento',
43
+ interest_rate: 0,
44
+ commission_opening: 0,
45
+ interest_arrears: 0,
46
+ }
47
+
48
+ export const cContract: oContract = {
49
+ id: "",
50
+ client: "",
51
+ address: cAddress,
52
+ device: cDevice,
53
+ financial: cFinancial,
54
+ by: "",
55
+ active: true
56
+ }
57
+
58
+ export class FactoryContract {
59
+
60
+ public static FormClient(client?: oClient) {
61
+ let data = cClient
62
+
63
+ if (client) data = client
64
+
65
+ return {
66
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
67
+ email: new UntypedFormControl(data.username, [Validators.required, Validators.email]),
68
+ phone: new UntypedFormControl(data.phone, [Validators.required, Validators.min(10)]),
69
+ curp: new UntypedFormControl(data.curp, [Validators.required, Validators.minLength(16)]),
70
+ userReferences: new UntypedFormArray([])
71
+ }
72
+ }
73
+
74
+ public static CreateUserReferenceFormObj(user: oUserReference) {
75
+ let data = cUserReference
76
+
77
+ if (user.name != "") data = user
78
+
79
+ return {
80
+ name: new UntypedFormControl(data.name, [Validators.required, Validators.minLength(10)]),
81
+ phone: new UntypedFormControl(data.phone, [Validators.required]),
82
+ relationship: new UntypedFormControl(data.relationship, [Validators.required]),
83
+ }
84
+ }
85
+
86
+ public static FormAddress(address?: oAddress) {
87
+ let data = cAddress
88
+
89
+ if (address) data = address
90
+
91
+ return {
92
+ street: new UntypedFormControl(data.street, Validators.required),
93
+ neighbor: new UntypedFormControl(data.neighbor, Validators.required),
94
+ cp: new UntypedFormControl(data.zip, Validators.required),
95
+ ext: new UntypedFormControl(data.ext, Validators.required),
96
+ int: new UntypedFormControl(data.int),
97
+ city: new UntypedFormControl(data.city, Validators.required),
98
+ state: new UntypedFormControl(data.state, Validators.required),
99
+ }
100
+ }
101
+
102
+ public static FormDevice(device?: oDevice) {
103
+ let data = cDevice
104
+
105
+ if (device) data = device
106
+
107
+ return {
108
+ model: new UntypedFormControl(data.device, Validators.required),
109
+ IMEI: new UntypedFormControl(data.IMEI, Validators.required),
110
+ ID: new UntypedFormControl(data.id),
111
+ }
112
+ }
113
+
114
+ public static FormFinancial(financial?: oFinancial) {
115
+ let data = cFinancial
116
+
117
+ if (financial) data = financial
118
+
119
+ data.credit_type = "Arrendamiento"
120
+ // data.deadlines.weeks = cBusinessDeadlines
121
+
122
+ return {
123
+ total: new UntypedFormControl(data.total, [Validators.required, Validators.min(1)]),
124
+ initial: new UntypedFormControl(data.initial, [Validators.required]),
125
+ financed: new UntypedFormControl(data.financed, Validators.min(1)),
126
+ weeklyPayment: new UntypedFormControl(data.weeklyPayment, [Validators.required, Validators.min(1)]),
127
+ deadlines: new UntypedFormControl(data.deadlines, [Validators.required]),
128
+ initDate: new UntypedFormControl(data.initDate),
129
+ provider: new UntypedFormControl(data.provider),
130
+
131
+ credit_type: new UntypedFormControl(data.credit_type ? data.credit_type : 0),
132
+ interest_rate: new UntypedFormControl(data.interest_rate ? data.interest_rate : 0), // interes credit dynamic
133
+ commission_opening: new UntypedFormControl(data.commission_opening ? data.commission_opening : 0),
134
+ interest_arrears: new UntypedFormControl(data.interest_arrears ? data.interest_arrears : 0), // intereses moratorios dynamic
135
+
136
+ amount_commission_opening: new UntypedFormControl(data.amount_commission_opening), // comision por apertura dynamic
137
+ principal_disbursed: new UntypedFormControl(data.principal_disbursed),
138
+ expected_disbursed: new UntypedFormControl(data.expected_disbursed)
139
+ }
140
+ }
141
+
142
+ public static CreateContractFromFormObj(data: any, finalPay: number) {
143
+ const date = new Date()
144
+
145
+ const device: oDevice = {
146
+ device: data["device"][0].model,
147
+ id: data["device"][0].ID,
148
+ IMEI: data["device"][0].IMEI
149
+ }
150
+ const address: oAddress = {
151
+ street: data["address"][0].street,
152
+ city: data["address"][0].city,
153
+ neighbor: data["address"][0].neighbor,
154
+ zip: data["address"][0].cp,
155
+ ext: data["address"][0].ext,
156
+ int: data["address"][0].int,
157
+ state: data["address"][0].state
158
+ }
159
+
160
+ const financial: oFinancial = {
161
+ total: Number(data["financial"][0].total),
162
+ initial: data["financial"][0].initial,
163
+ deadlines: data["financial"][0].deadlines,
164
+ progress: [],
165
+ pendingOf: [],
166
+ weeklyPayment: data["financial"][0].weeklyPayment,
167
+ interest: data["financial"][0].interest_rate,
168
+ finalDate: date.getTime() + (data["financial"][0].deadlines.weeks * (604800 * 1000)),
169
+ initDate: date.getDate(),
170
+ dayCut: date.getDate(),
171
+ provider: data["financial"][0].provider,
172
+ finalPayment: finalPay,
173
+ financed: data["financial"][0].financed,
174
+ nextPayment: data["financial"][0].nextPayment
175
+ }
176
+ if (data["financial"][0].provider == eProvider.DynamiCore) {
177
+ financial.initial = data["financial"][0].amount_commission_opening ? Number(data["financial"][0].amount_commission_opening) : 0
178
+ financial.expected_disbursed = data["financial"][0].expected_disbursed ? Number(data["financial"][0].expected_disbursed) : 0
179
+ financial.principal_disbursed = data["financial"][0].principal_disbursed ? Number(data["financial"][0].principal_disbursed) : 0
180
+ financial.interest_arrears = data["financial"][0].interest_rate ? Number(data["financial"][0].interest_rate) : 0
181
+ financial.commission_opening = data["financial"][0].commission_opening ? Number(data["financial"][0].commission_opening) : 0
182
+ financial.credit_type = data["financial"][0].credit_type ? data["financial"][0].credit_type : ""
183
+ financial.clabe = data["financial"][0].clabe ? data["financial"][0].clabe : ""
184
+ }
185
+
186
+ if (data["financial"][0].amount_commission_opening != undefined) {
187
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
188
+ financial.initial = Number(data["financial"][0].amount_commission_opening)
189
+ else
190
+ financial.initial = Number(data["financial"][0].initial)
191
+ }
192
+
193
+ if (Number(data["financial"][0].amount_commission_opening) > 0)
194
+ financial.amount_commission_opening = Number(data["financial"][0].amount_commission_opening)
195
+ else
196
+ financial.amount_commission_opening = financial.initial
197
+
198
+ if (financial.nextPayment == undefined) financial.nextPayment = 0
199
+
200
+ const contract: oContract = {
201
+ id: "",
202
+ client: "",
203
+ address: address,
204
+ device: device,
205
+ financial: financial,
206
+ by: "",
207
+ active: true,
208
+ lastPayment: date.getTime(),
209
+ createdAt: date.getTime()
210
+ }
211
+ return contract
212
+ }
213
+
214
+ public static CreateContractToConektaObj(data: oContract, monthlyPay: number, finalPay: number) {
215
+ const o: any = {}
216
+
217
+ const device: oDevice = {
218
+ device: data.device.device,
219
+ id: data.device.id,
220
+ IMEI: data.device.IMEI
221
+ }
222
+ const address: oAddress = {
223
+ street: data.address.street,
224
+ city: data.address.city,
225
+ neighbor: data.address.neighbor,
226
+ zip: data.address.zip,
227
+ ext: data.address.ext,
228
+ int: data.address.int,
229
+ state: data.address.state
230
+ }
231
+ const financial: oFinancial = {
232
+ total: data.financial.total,
233
+ initial: data.financial.initial,
234
+ deadlines: data.financial.deadlines,
235
+ progress: data.financial.progress,
236
+ pendingOf: data.financial.pendingOf,
237
+ weeklyPayment: data.financial.weeklyPayment,
238
+ interest: data.financial.interest,
239
+ finalDate: data.financial.finalDate,
240
+ initDate: data.financial.initDate,
241
+ dayCut: data.financial.dayCut,
242
+ provider: data.financial.provider,
243
+ finalPayment: data.financial.finalPayment,
244
+ financed: data.financial.financed,
245
+ nextPayment: data.financial.nextPayment
246
+ }
247
+ const contract: oContract = {
248
+ id: "",
249
+ client: "",
250
+ address: address,
251
+ device: device,
252
+ financial: financial,
253
+ by: "",
254
+ active: true
255
+ }
256
+ return contract
257
+ }
258
+
259
+ public static CreateAuthForm(username: string, curp: string) {
260
+ const password: string = this.createPassword(curp)
261
+ return {
262
+ username: new UntypedFormControl(username, Validators.required),
263
+ password: new UntypedFormControl(password, Validators.required),
264
+ }
265
+ }
266
+
267
+ public static createPassword(curp: string): string {
268
+ const _curp = curp.split("")
269
+ let password = ""
270
+ const limit = 7
271
+
272
+ if (_curp.length < 16) return ""
273
+
274
+ password += _curp[0].toLowerCase()
275
+
276
+ for (let i = 1; i <= limit; i++)
277
+ password += _curp[i].toUpperCase()
278
+
279
+ password += `*`
280
+ return password
281
+ }
282
+
283
+ public static MapperTypeContCli_Contract(_contract: tyClientContract): oContract {
284
+ const contract: oContract = {
285
+ id: _contract.contract!,
286
+ client: _contract.client,
287
+ address: _contract.address,
288
+ device: _contract.device,
289
+ financial: _contract.financial,
290
+ by: _contract.by,
291
+ active: _contract.active,
292
+ lastPayment: _contract.lastPayment,
293
+ createdAt: _contract.createdAt,
294
+ dynamicAccount: _contract.dynamicAccount,
295
+ }
296
+
297
+ return contract
298
+ }
299
+
300
+ public static MapperSyncContractDynamic(base: oContract, account: IDCAccount): oContract {
301
+ let nContract = base
302
+ let _financial = base.financial
303
+ let _device = base.device
304
+
305
+
306
+ const financial: oFinancial = {
307
+ total: _financial.total,
308
+ initial: account.properties.amount_commission_opening ? account.properties.amount_commission_opening : _financial.initial,
309
+ deadlines: _financial.deadlines,
310
+ progress: _financial.progress ? _financial.progress : [],
311
+ pendingOf: _financial.pendingOf ? _financial.pendingOf : [],
312
+ weeklyPayment: _financial.weeklyPayment,
313
+ interest: _financial.interest,
314
+ finalDate: _financial.finalDate,
315
+ initDate: _financial.initDate,
316
+ dayCut: _financial.dayCut,
317
+ provider: _financial.provider,
318
+ finalPayment: _financial.finalPayment,
319
+ financed: _financial.financed,
320
+ nextPayment: _financial.nextPayment ? _financial.nextPayment : 0,
321
+
322
+ amount_commission_opening:
323
+ account.properties.amount_commission_opening,
324
+
325
+ expected_disbursed:
326
+ account.properties.expected_disbursed ?
327
+ Number(account.properties.expected_disbursed) :
328
+ Number(_financial.expected_disbursed),
329
+
330
+ principal_disbursed:
331
+ account.properties.principal_disbursed ?
332
+ account.properties.principal_disbursed :
333
+ _financial.principal_disbursed,
334
+
335
+ commission_opening:
336
+ account.config.commission_opening ?
337
+ Number(account.config.commission_opening) :
338
+ Number(_financial.commission_opening),
339
+
340
+ credit_type:
341
+ account.config.credit_type ? account.config.credit_type : _financial.credit_type,
342
+
343
+ clabe:
344
+ String(account.properties.clabe ? account.properties.clabe : _financial.clabe)
345
+ }
346
+
347
+ const interestArrears = account.config.interest_arrears
348
+ const prevInterestArrears = _financial.interest_arrears
349
+ if (interestArrears != undefined) {
350
+ financial.interest_arrears = interestArrears
351
+ } else if (prevInterestArrears != undefined) {
352
+ financial.interest_arrears = prevInterestArrears
353
+ } else {
354
+ financial.interest_arrears = 0
355
+ }
356
+
357
+ const interest = account.config.interest_rate
358
+ const prevInterest = _financial.interest
359
+ if (interest != undefined) {
360
+ financial.interest = interest
361
+ } else if (prevInterest != undefined) {
362
+ financial.interest = prevInterest
363
+ } else {
364
+ financial.interest = 0
365
+ }
366
+
367
+ if (account.properties.amount_commission_opening != undefined) {
368
+ if (Number(account.properties.amount_commission_opening) > 0) {
369
+ financial.initial = Number(account.properties.amount_commission_opening)
370
+ financial.amount_commission_opening = Number(account.properties.amount_commission_opening)
371
+ } else {
372
+ financial.initial = Number(_financial.initial)
373
+ financial.amount_commission_opening = financial.initial
374
+ }
375
+ }
376
+
377
+ const seller: string | undefined = account.properties.seller_name
378
+ nContract.by = seller != null ? seller : ""
379
+
380
+ nContract.device.id = _device.id ? _device.id : ""
381
+
382
+ nContract.financial = financial
383
+ return nContract
384
+ }
385
+ }
386
+
@@ -0,0 +1,19 @@
1
+ import {oContractMetrics} from '../objects/oGlobal';
2
+
3
+ export const cContractMetrics: oContractMetrics = {
4
+ total: 0,
5
+ activated: 0,
6
+ paused: 0,
7
+ completed: 0,
8
+ canceled: 0,
9
+ late: 0,
10
+ conektaCount: 0,
11
+ dynamicCount: 0,
12
+ passportCount: 0,
13
+ rateTotal: 0,
14
+ rateActive: 0,
15
+ ratePaused: 0,
16
+ rateComplete: 0,
17
+ rateCanceled: 0,
18
+ rateLate: 0
19
+ }