ravcredit-lib 0.0.11 → 0.0.13
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.
- package/fesm2022/ravcredit-lib.mjs +2088 -0
- package/fesm2022/ravcredit-lib.mjs.map +1 -0
- package/index.d.ts +1654 -0
- package/package.json +25 -13
- package/ng-package.json +0 -7
- package/src/lib/ravcredit-lib.component.spec.ts +0 -23
- package/src/lib/ravcredit-lib.component.ts +0 -16
- package/src/lib/ravcredit-lib.service.spec.ts +0 -16
- package/src/lib/ravcredit-lib.service.ts +0 -9
- package/src/lib/v1/const/constants.ts +0 -35
- package/src/lib/v1/dto/AddressDto.ts +0 -27
- package/src/lib/v1/dto/BusinessDeadlineDto.ts +0 -9
- package/src/lib/v1/dto/ConektaDto.ts +0 -386
- package/src/lib/v1/dto/ContractDto.ts +0 -46
- package/src/lib/v1/dto/CustomerDto.ts +0 -47
- package/src/lib/v1/dto/DeviceDto.ts +0 -13
- package/src/lib/v1/dto/DynamiCoreDto.ts +0 -1017
- package/src/lib/v1/dto/FinancialDto.ts +0 -156
- package/src/lib/v1/dto/PassportDto.ts +0 -143
- package/src/lib/v1/dto/PayLinkResDto.ts +0 -144
- package/src/lib/v1/dto/PayOrderResAlternaDto.ts +0 -348
- package/src/lib/v1/dto/PayOrderResOxxoDto.ts +0 -254
- package/src/lib/v1/dto/PaymentLinkDto.ts +0 -161
- package/src/lib/v1/dto/ScheduleDto.ts +0 -17
- package/src/lib/v1/dto/UserDto.ts +0 -27
- package/src/lib/v1/dto/WeekScheduleDTO.ts +0 -46
- package/src/lib/v1/idb/idb.service.spec.ts +0 -16
- package/src/lib/v1/idb/indexed-db.service.ts +0 -396
- package/src/lib/v1/objects/oAddress.ts +0 -19
- package/src/lib/v1/objects/oBusiness.ts +0 -112
- package/src/lib/v1/objects/oClient.ts +0 -46
- package/src/lib/v1/objects/oConekta.ts +0 -408
- package/src/lib/v1/objects/oContract.ts +0 -30
- package/src/lib/v1/objects/oContractAll.ts +0 -38
- package/src/lib/v1/objects/oCustomer.ts +0 -36
- package/src/lib/v1/objects/oDevice.ts +0 -5
- package/src/lib/v1/objects/oFinancial.ts +0 -32
- package/src/lib/v1/objects/oGlobal.ts +0 -186
- package/src/lib/v1/objects/oLogIn.ts +0 -43
- package/src/lib/v1/objects/oNewPayment.ts +0 -18
- package/src/lib/v1/objects/oNotification.ts +0 -34
- package/src/lib/v1/objects/oPassport.ts +0 -65
- package/src/lib/v1/objects/oUser.ts +0 -35
- package/src/lib/v1/objects/oVerification.ts +0 -48
- package/src/lib/v1/util/UtilBusiness.ts +0 -186
- package/src/lib/v1/util/UtilClient.ts +0 -285
- package/src/lib/v1/util/UtilConekta.ts +0 -97
- package/src/lib/v1/util/UtilContract.ts +0 -386
- package/src/lib/v1/util/UtilDashboard.ts +0 -19
- package/src/lib/v1/util/UtilDynamiCore.ts +0 -752
- package/src/lib/v1/util/UtilNotification.ts +0 -46
- package/src/lib/v1/util/UtilPassport.ts +0 -32
- package/src/lib/v1/util/UtilPayment.ts +0 -22
- package/src/lib/v1/util/UtilTime.ts +0 -181
- package/src/lib/v1/util/UtilsHttp.ts +0 -11
- package/src/lib/v2/const/constants.ts +0 -38
- package/src/lib/v2/messaging/messaging.ts +0 -10
- package/src/public-api.ts +0 -37
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -0,0 +1,2088 @@
|
|
|
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 score = {
|
|
716
|
+
name: "",
|
|
717
|
+
score: 0
|
|
718
|
+
};
|
|
719
|
+
const catalog = {
|
|
720
|
+
name: "",
|
|
721
|
+
description: "",
|
|
722
|
+
id: "",
|
|
723
|
+
createdAt: 0
|
|
724
|
+
};
|
|
725
|
+
const brand = {
|
|
726
|
+
name: "",
|
|
727
|
+
id: "",
|
|
728
|
+
description: ""
|
|
729
|
+
};
|
|
730
|
+
const category = {
|
|
731
|
+
name: "",
|
|
732
|
+
id: "",
|
|
733
|
+
createAt: 0
|
|
734
|
+
};
|
|
735
|
+
const deviceV2 = {
|
|
736
|
+
name: "",
|
|
737
|
+
id: "",
|
|
738
|
+
createAt: new Date().getTime(),
|
|
739
|
+
category: category,
|
|
740
|
+
brand: brand,
|
|
741
|
+
price: 0,
|
|
742
|
+
model: "",
|
|
743
|
+
imageUrl: [],
|
|
744
|
+
paymentOption: [],
|
|
745
|
+
catalog: catalog,
|
|
746
|
+
offers: [],
|
|
747
|
+
score: score,
|
|
748
|
+
IMEI: ""
|
|
749
|
+
};
|
|
750
|
+
const device = {
|
|
751
|
+
device: data.device.device,
|
|
752
|
+
id: data.device.id,
|
|
753
|
+
IMEI: data.device.IMEI
|
|
754
|
+
};
|
|
755
|
+
const address = {
|
|
756
|
+
street: data.address.street,
|
|
757
|
+
city: data.address.city,
|
|
758
|
+
neighbor: data.address.neighbor,
|
|
759
|
+
zip: data.address.zip,
|
|
760
|
+
ext: data.address.ext,
|
|
761
|
+
int: data.address.int,
|
|
762
|
+
state: data.address.state
|
|
763
|
+
};
|
|
764
|
+
const financial = {
|
|
765
|
+
total: data.financial.total,
|
|
766
|
+
initial: data.financial.initial,
|
|
767
|
+
deadlines: data.financial.deadlines,
|
|
768
|
+
progress: data.financial.progress,
|
|
769
|
+
pendingOf: data.financial.pendingOf,
|
|
770
|
+
weeklyPayment: data.financial.weeklyPayment,
|
|
771
|
+
interest: data.financial.interest,
|
|
772
|
+
finalDate: data.financial.finalDate,
|
|
773
|
+
initDate: data.financial.initDate,
|
|
774
|
+
dayCut: data.financial.dayCut,
|
|
775
|
+
provider: data.financial.provider,
|
|
776
|
+
finalPayment: data.financial.finalPayment,
|
|
777
|
+
financed: data.financial.financed,
|
|
778
|
+
nextPayment: data.financial.nextPayment
|
|
779
|
+
};
|
|
780
|
+
const contract = {
|
|
781
|
+
id: "",
|
|
782
|
+
client: "",
|
|
783
|
+
address: address,
|
|
784
|
+
device: device,
|
|
785
|
+
financial: financial,
|
|
786
|
+
by: "",
|
|
787
|
+
active: true
|
|
788
|
+
};
|
|
789
|
+
return contract;
|
|
790
|
+
}
|
|
791
|
+
static CreateAuthForm(username, curp) {
|
|
792
|
+
const password = this.createPassword(curp);
|
|
793
|
+
return {
|
|
794
|
+
username: new UntypedFormControl(username, Validators.required),
|
|
795
|
+
password: new UntypedFormControl(password, Validators.required),
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
static createPassword(curp) {
|
|
799
|
+
const _curp = curp.split("");
|
|
800
|
+
let password = "";
|
|
801
|
+
const limit = 7;
|
|
802
|
+
if (_curp.length < 16)
|
|
803
|
+
return "";
|
|
804
|
+
password += _curp[0].toLowerCase();
|
|
805
|
+
for (let i = 1; i <= limit; i++)
|
|
806
|
+
password += _curp[i].toUpperCase();
|
|
807
|
+
password += `*`;
|
|
808
|
+
return password;
|
|
809
|
+
}
|
|
810
|
+
static MapperTypeContCli_Contract(_contract) {
|
|
811
|
+
const contract = {
|
|
812
|
+
id: _contract.contract,
|
|
813
|
+
client: _contract.client,
|
|
814
|
+
address: _contract.address,
|
|
815
|
+
device: _contract.device,
|
|
816
|
+
financial: _contract.financial,
|
|
817
|
+
by: _contract.by,
|
|
818
|
+
active: _contract.active,
|
|
819
|
+
lastPayment: _contract.lastPayment,
|
|
820
|
+
createdAt: _contract.createdAt,
|
|
821
|
+
dynamicAccount: _contract.dynamicAccount,
|
|
822
|
+
};
|
|
823
|
+
return contract;
|
|
824
|
+
}
|
|
825
|
+
static MapperSyncContractDynamic(base, account) {
|
|
826
|
+
let nContract = base;
|
|
827
|
+
let _financial = base.financial;
|
|
828
|
+
let _device = base.device;
|
|
829
|
+
const financial = {
|
|
830
|
+
total: _financial.total,
|
|
831
|
+
initial: account.properties.amount_commission_opening ? account.properties.amount_commission_opening : _financial.initial,
|
|
832
|
+
deadlines: _financial.deadlines,
|
|
833
|
+
progress: _financial.progress ? _financial.progress : [],
|
|
834
|
+
pendingOf: _financial.pendingOf ? _financial.pendingOf : [],
|
|
835
|
+
weeklyPayment: _financial.weeklyPayment,
|
|
836
|
+
interest: _financial.interest,
|
|
837
|
+
finalDate: _financial.finalDate,
|
|
838
|
+
initDate: _financial.initDate,
|
|
839
|
+
dayCut: _financial.dayCut,
|
|
840
|
+
provider: _financial.provider,
|
|
841
|
+
finalPayment: _financial.finalPayment,
|
|
842
|
+
financed: _financial.financed,
|
|
843
|
+
nextPayment: _financial.nextPayment ? _financial.nextPayment : 0,
|
|
844
|
+
amount_commission_opening: account.properties.amount_commission_opening,
|
|
845
|
+
expected_disbursed: account.properties.expected_disbursed ?
|
|
846
|
+
Number(account.properties.expected_disbursed) :
|
|
847
|
+
Number(_financial.expected_disbursed),
|
|
848
|
+
principal_disbursed: account.properties.principal_disbursed ?
|
|
849
|
+
account.properties.principal_disbursed :
|
|
850
|
+
_financial.principal_disbursed,
|
|
851
|
+
commission_opening: account.config.commission_opening ?
|
|
852
|
+
Number(account.config.commission_opening) :
|
|
853
|
+
Number(_financial.commission_opening),
|
|
854
|
+
credit_type: account.config.credit_type ? account.config.credit_type : _financial.credit_type,
|
|
855
|
+
clabe: String(account.properties.clabe ? account.properties.clabe : _financial.clabe)
|
|
856
|
+
};
|
|
857
|
+
const interestArrears = account.config.interest_arrears;
|
|
858
|
+
const prevInterestArrears = _financial.interest_arrears;
|
|
859
|
+
if (interestArrears != undefined) {
|
|
860
|
+
financial.interest_arrears = interestArrears;
|
|
861
|
+
}
|
|
862
|
+
else if (prevInterestArrears != undefined) {
|
|
863
|
+
financial.interest_arrears = prevInterestArrears;
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
financial.interest_arrears = 0;
|
|
867
|
+
}
|
|
868
|
+
const interest = account.config.interest_rate;
|
|
869
|
+
const prevInterest = _financial.interest;
|
|
870
|
+
if (interest != undefined) {
|
|
871
|
+
financial.interest = interest;
|
|
872
|
+
}
|
|
873
|
+
else if (prevInterest != undefined) {
|
|
874
|
+
financial.interest = prevInterest;
|
|
875
|
+
}
|
|
876
|
+
else {
|
|
877
|
+
financial.interest = 0;
|
|
878
|
+
}
|
|
879
|
+
if (account.properties.amount_commission_opening != undefined) {
|
|
880
|
+
if (Number(account.properties.amount_commission_opening) > 0) {
|
|
881
|
+
financial.initial = Number(account.properties.amount_commission_opening);
|
|
882
|
+
financial.amount_commission_opening = Number(account.properties.amount_commission_opening);
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
financial.initial = Number(_financial.initial);
|
|
886
|
+
financial.amount_commission_opening = financial.initial;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
const seller = account.properties.seller_name;
|
|
890
|
+
nContract.by = seller != null ? seller : "";
|
|
891
|
+
nContract.device.id = _device.id ? _device.id : "";
|
|
892
|
+
nContract.financial = financial;
|
|
893
|
+
return nContract;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
var eRoles;
|
|
898
|
+
(function (eRoles) {
|
|
899
|
+
eRoles["Administrator"] = "Administrator";
|
|
900
|
+
eRoles["Seller"] = "Seller";
|
|
901
|
+
eRoles["Consultant"] = "Consultant";
|
|
902
|
+
})(eRoles || (eRoles = {}));
|
|
903
|
+
var eProcessStatus;
|
|
904
|
+
(function (eProcessStatus) {
|
|
905
|
+
eProcessStatus["IDLE"] = "IDLE";
|
|
906
|
+
eProcessStatus["ERROR"] = "ERROR";
|
|
907
|
+
eProcessStatus["CANCELED"] = "CANCELED";
|
|
908
|
+
eProcessStatus["COMPLETE"] = "COMPLETE";
|
|
909
|
+
eProcessStatus["PROCESSING"] = "PROCESSING";
|
|
910
|
+
eProcessStatus["WAITING"] = "WAITING";
|
|
911
|
+
})(eProcessStatus || (eProcessStatus = {}));
|
|
912
|
+
var eLoginStatus;
|
|
913
|
+
(function (eLoginStatus) {
|
|
914
|
+
eLoginStatus["IDLE"] = "IDLE";
|
|
915
|
+
eLoginStatus["ERROR"] = "ERROR";
|
|
916
|
+
eLoginStatus["AUTHORIZED"] = "AUTHORIZED";
|
|
917
|
+
eLoginStatus["CHECKING"] = "CHECKING";
|
|
918
|
+
eLoginStatus["NOAUTHORIZED"] = "NOAUTHORIZED";
|
|
919
|
+
eLoginStatus["NOTFOUND"] = "NOTFOUND";
|
|
920
|
+
eLoginStatus["ERRORPASSWORD"] = "ERRORPASSWORD";
|
|
921
|
+
})(eLoginStatus || (eLoginStatus = {}));
|
|
922
|
+
var eClientStatus;
|
|
923
|
+
(function (eClientStatus) {
|
|
924
|
+
eClientStatus["ACTIVE"] = "active";
|
|
925
|
+
eClientStatus["COMPLETED"] = "completed";
|
|
926
|
+
eClientStatus["PAUSED"] = "paused";
|
|
927
|
+
eClientStatus["CANCELED"] = "canceled";
|
|
928
|
+
eClientStatus["LATE"] = "late";
|
|
929
|
+
})(eClientStatus || (eClientStatus = {}));
|
|
930
|
+
const cSingleOptionClientStatus = {
|
|
931
|
+
viewValue: "",
|
|
932
|
+
value: ""
|
|
933
|
+
};
|
|
934
|
+
const cOptionsClientStatus = [
|
|
935
|
+
{
|
|
936
|
+
value: eClientStatus.ACTIVE,
|
|
937
|
+
viewValue: "Activar"
|
|
938
|
+
}, {
|
|
939
|
+
value: eClientStatus.COMPLETED,
|
|
940
|
+
viewValue: "Completar"
|
|
941
|
+
}, {
|
|
942
|
+
value: eClientStatus.PAUSED,
|
|
943
|
+
viewValue: "Pausar"
|
|
944
|
+
}, {
|
|
945
|
+
value: eClientStatus.LATE,
|
|
946
|
+
viewValue: "Marcar con atraso"
|
|
947
|
+
}, {
|
|
948
|
+
value: eClientStatus.CANCELED,
|
|
949
|
+
viewValue: "Cancelar"
|
|
950
|
+
}
|
|
951
|
+
];
|
|
952
|
+
const eRolesSelect = [
|
|
953
|
+
{
|
|
954
|
+
value: eRoles.Administrator,
|
|
955
|
+
viewValue: eRoles.Administrator
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
value: eRoles.Consultant,
|
|
959
|
+
viewValue: eRoles.Consultant
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
value: eRoles.Seller,
|
|
963
|
+
viewValue: eRoles.Seller
|
|
964
|
+
},
|
|
965
|
+
];
|
|
966
|
+
const cPaymentDalay = {
|
|
967
|
+
today: 0,
|
|
968
|
+
nextPayment: 0,
|
|
969
|
+
daysDelay: 0,
|
|
970
|
+
late: false,
|
|
971
|
+
};
|
|
972
|
+
const snackBarConfigAction = {
|
|
973
|
+
horizontalPosition: "start"
|
|
974
|
+
};
|
|
975
|
+
const snackBarConfigNoAction = {
|
|
976
|
+
duration: 4000,
|
|
977
|
+
horizontalPosition: "start"
|
|
978
|
+
};
|
|
979
|
+
const cTyClientContract = { ...cClient, ...cContract };
|
|
980
|
+
|
|
981
|
+
var eAuthActions;
|
|
982
|
+
(function (eAuthActions) {
|
|
983
|
+
eAuthActions["delete"] = "delete";
|
|
984
|
+
eAuthActions["auth"] = "auth";
|
|
985
|
+
})(eAuthActions || (eAuthActions = {}));
|
|
986
|
+
var eAuthType;
|
|
987
|
+
(function (eAuthType) {
|
|
988
|
+
eAuthType["auth"] = "auth";
|
|
989
|
+
eAuthType["login"] = "login";
|
|
990
|
+
eAuthType["idle"] = "";
|
|
991
|
+
})(eAuthType || (eAuthType = {}));
|
|
992
|
+
const cAuthConfig = {
|
|
993
|
+
title: "",
|
|
994
|
+
desc: "",
|
|
995
|
+
data: true,
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
const cTopic = "RavCreditClients";
|
|
999
|
+
var eNotificationType;
|
|
1000
|
+
(function (eNotificationType) {
|
|
1001
|
+
eNotificationType["GLOBAL"] = "global";
|
|
1002
|
+
eNotificationType["USER"] = "user";
|
|
1003
|
+
eNotificationType["PAYMENT"] = "payment";
|
|
1004
|
+
})(eNotificationType || (eNotificationType = {}));
|
|
1005
|
+
const cNotification = {
|
|
1006
|
+
notification: {
|
|
1007
|
+
title: "",
|
|
1008
|
+
body: ""
|
|
1009
|
+
},
|
|
1010
|
+
data: {
|
|
1011
|
+
route: ""
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
var ePassportTypes;
|
|
1016
|
+
(function (ePassportTypes) {
|
|
1017
|
+
ePassportTypes["CREATE"] = "create_references";
|
|
1018
|
+
ePassportTypes["SEND"] = "send_references";
|
|
1019
|
+
})(ePassportTypes || (ePassportTypes = {}));
|
|
1020
|
+
/** ******************************** */
|
|
1021
|
+
|
|
1022
|
+
// export enum oGenVerificationProvider {
|
|
1023
|
+
// pending, approved, expired
|
|
1024
|
+
// }
|
|
1025
|
+
//
|
|
1026
|
+
// export interface oVerificationLookup {
|
|
1027
|
+
// carrier: any[]
|
|
1028
|
+
// }
|
|
1029
|
+
//
|
|
1030
|
+
// export interface oVerificationSenCodeAttempt {
|
|
1031
|
+
// attempt_sid: any[],
|
|
1032
|
+
// channel: any[],
|
|
1033
|
+
// time: any[]
|
|
1034
|
+
// }
|
|
1035
|
+
//
|
|
1036
|
+
// export interface oGenVerification {
|
|
1037
|
+
// Sid: string
|
|
1038
|
+
// ServiceSid: string,
|
|
1039
|
+
// AccountSid: string,
|
|
1040
|
+
// To: string,
|
|
1041
|
+
// Channel: any,
|
|
1042
|
+
// Status: oGenVerificationProvider,
|
|
1043
|
+
// Valid: boolean,
|
|
1044
|
+
// Lookup: oVerificationLookup,
|
|
1045
|
+
// SendCodeAttempts: oVerificationSenCodeAttempt[],
|
|
1046
|
+
// DateCreated: string,
|
|
1047
|
+
// DateUpdated: string,
|
|
1048
|
+
// Url: string
|
|
1049
|
+
// }
|
|
1050
|
+
//
|
|
1051
|
+
// export interface oVerification {
|
|
1052
|
+
// Sid : string,
|
|
1053
|
+
// ServiceSid : string,
|
|
1054
|
+
// AccountSid : string,
|
|
1055
|
+
// To : string,
|
|
1056
|
+
// Channel : any,
|
|
1057
|
+
// Status : oGenVerificationProvider,
|
|
1058
|
+
// Valid : boolean,
|
|
1059
|
+
// DateCreated : string,
|
|
1060
|
+
// DateUpdated : string
|
|
1061
|
+
// }
|
|
1062
|
+
var eVerificationStep;
|
|
1063
|
+
(function (eVerificationStep) {
|
|
1064
|
+
eVerificationStep["IDLE"] = "IDLE";
|
|
1065
|
+
eVerificationStep["ERROR"] = "ERROR";
|
|
1066
|
+
eVerificationStep["COMPLETED"] = "COMPLETED";
|
|
1067
|
+
eVerificationStep["IN_PROGRESS"] = "IN_PROGRESS";
|
|
1068
|
+
eVerificationStep["INVALID"] = "INVALID";
|
|
1069
|
+
eVerificationStep["SUSPENDED"] = "SUSPENDED";
|
|
1070
|
+
eVerificationStep["CANCELLED"] = "CANCELLED";
|
|
1071
|
+
})(eVerificationStep || (eVerificationStep = {}));
|
|
1072
|
+
var eVerificationStatus;
|
|
1073
|
+
(function (eVerificationStatus) {
|
|
1074
|
+
eVerificationStatus["APPROVED"] = "approved";
|
|
1075
|
+
eVerificationStatus["CANCELLED"] = "cancelled";
|
|
1076
|
+
})(eVerificationStatus || (eVerificationStatus = {}));
|
|
1077
|
+
var eVerificationChannel;
|
|
1078
|
+
(function (eVerificationChannel) {
|
|
1079
|
+
eVerificationChannel["SMS"] = "sms";
|
|
1080
|
+
eVerificationChannel["WHATSAPP"] = "whatsapp";
|
|
1081
|
+
eVerificationChannel["CALL"] = "call";
|
|
1082
|
+
eVerificationChannel["EMAIL"] = "email";
|
|
1083
|
+
eVerificationChannel["SNA"] = "sna";
|
|
1084
|
+
})(eVerificationChannel || (eVerificationChannel = {}));
|
|
1085
|
+
|
|
1086
|
+
class UtilsHttp {
|
|
1087
|
+
static CreateHeadersApi(token) {
|
|
1088
|
+
return {
|
|
1089
|
+
'Content-Type': 'application/json',
|
|
1090
|
+
'Accept': 'application/json',
|
|
1091
|
+
'Access-Control-Allow-Headers': 'Content-Type',
|
|
1092
|
+
'Authorization': `Bearer ${token}`
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
static CreateSimpleHeadersApi() {
|
|
1096
|
+
return {
|
|
1097
|
+
'Content-Type': 'application/json',
|
|
1098
|
+
'Accept': 'application/json',
|
|
1099
|
+
'Access-Control-Allow-Headers': 'Content-Type',
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
var eReferenceStatusRav;
|
|
1105
|
+
(function (eReferenceStatusRav) {
|
|
1106
|
+
eReferenceStatusRav["Disponible"] = "Disponible";
|
|
1107
|
+
eReferenceStatusRav["Active"] = "Activo con credito vigente";
|
|
1108
|
+
eReferenceStatusRav["ActiveEnded"] = "Activo sin credito vigente";
|
|
1109
|
+
eReferenceStatusRav["Registered"] = "Registrado";
|
|
1110
|
+
eReferenceStatusRav["NonRegistered"] = "No registrado";
|
|
1111
|
+
eReferenceStatusRav["NonVerified"] = "No verificado";
|
|
1112
|
+
eReferenceStatusRav["Rejected"] = "Rechazado";
|
|
1113
|
+
eReferenceStatusRav["Pending"] = "Pendiente";
|
|
1114
|
+
})(eReferenceStatusRav || (eReferenceStatusRav = {}));
|
|
1115
|
+
var eAccountDynamicStatus;
|
|
1116
|
+
(function (eAccountDynamicStatus) {
|
|
1117
|
+
eAccountDynamicStatus["OK"] = "Con cuenta activa";
|
|
1118
|
+
eAccountDynamicStatus["NOK"] = "Sin cuenta activa";
|
|
1119
|
+
})(eAccountDynamicStatus || (eAccountDynamicStatus = {}));
|
|
1120
|
+
//
|
|
1121
|
+
// export enum eAccountDynamicRegister {
|
|
1122
|
+
// "Active" = "Activo", // Ok
|
|
1123
|
+
// "NonAuthorized" = "No autorizado",
|
|
1124
|
+
// "Authorized" = "Autorizado", // Non ref
|
|
1125
|
+
// "Accepted" = "Aceptado", // Non ref
|
|
1126
|
+
// "Rejected" = "Rechazado", // Non ref
|
|
1127
|
+
// "Pending" = "Pendiente", // Non ref
|
|
1128
|
+
// "NotFound" = "No registrado"
|
|
1129
|
+
// }
|
|
1130
|
+
var eClientDynamicStatus;
|
|
1131
|
+
(function (eClientDynamicStatus) {
|
|
1132
|
+
eClientDynamicStatus["Active"] = "Active";
|
|
1133
|
+
eClientDynamicStatus["Pending"] = "Pending";
|
|
1134
|
+
eClientDynamicStatus["Accepted"] = "Accepted";
|
|
1135
|
+
eClientDynamicStatus["Rejected"] = "Rejected";
|
|
1136
|
+
eClientDynamicStatus["approved"] = "Aprobado";
|
|
1137
|
+
})(eClientDynamicStatus || (eClientDynamicStatus = {}));
|
|
1138
|
+
const cClientDynamicStatus = {
|
|
1139
|
+
Active: {
|
|
1140
|
+
value: "Active",
|
|
1141
|
+
viewValue: "Activo"
|
|
1142
|
+
},
|
|
1143
|
+
Pending: {
|
|
1144
|
+
value: "Pending",
|
|
1145
|
+
viewValue: "Pendiente"
|
|
1146
|
+
},
|
|
1147
|
+
Accepted: {
|
|
1148
|
+
value: "Accepted",
|
|
1149
|
+
viewValue: "Pre autorizado"
|
|
1150
|
+
},
|
|
1151
|
+
Rejected: {
|
|
1152
|
+
value: "Rejected",
|
|
1153
|
+
viewValue: "Rechazado"
|
|
1154
|
+
},
|
|
1155
|
+
Idle: {
|
|
1156
|
+
value: "Idle",
|
|
1157
|
+
viewValue: ""
|
|
1158
|
+
},
|
|
1159
|
+
};
|
|
1160
|
+
var eContractSteps;
|
|
1161
|
+
(function (eContractSteps) {
|
|
1162
|
+
eContractSteps["idle"] = "idle";
|
|
1163
|
+
eContractSteps["general"] = "General";
|
|
1164
|
+
eContractSteps["address"] = "Address";
|
|
1165
|
+
eContractSteps["device"] = "Device";
|
|
1166
|
+
eContractSteps["financial"] = "Financial";
|
|
1167
|
+
eContractSteps["app"] = "App";
|
|
1168
|
+
})(eContractSteps || (eContractSteps = {}));
|
|
1169
|
+
const cIDCDataPii = {
|
|
1170
|
+
icc: "",
|
|
1171
|
+
rfc: "",
|
|
1172
|
+
sex: "",
|
|
1173
|
+
city: "",
|
|
1174
|
+
curp: "",
|
|
1175
|
+
days: "",
|
|
1176
|
+
imei: "",
|
|
1177
|
+
name: "",
|
|
1178
|
+
step: "",
|
|
1179
|
+
term: "",
|
|
1180
|
+
brand: "",
|
|
1181
|
+
email: "",
|
|
1182
|
+
model: "",
|
|
1183
|
+
phone: "",
|
|
1184
|
+
score: "",
|
|
1185
|
+
state: "",
|
|
1186
|
+
amount: "",
|
|
1187
|
+
colony: "",
|
|
1188
|
+
period: "",
|
|
1189
|
+
street: "",
|
|
1190
|
+
ticket: "",
|
|
1191
|
+
num_ext: "",
|
|
1192
|
+
num_int: "",
|
|
1193
|
+
zipcode: "",
|
|
1194
|
+
evidence: "",
|
|
1195
|
+
financed: "",
|
|
1196
|
+
house_is: "",
|
|
1197
|
+
lastname: "",
|
|
1198
|
+
type_job: "",
|
|
1199
|
+
birthdate: "",
|
|
1200
|
+
birthstate: "",
|
|
1201
|
+
dicio_data: "",
|
|
1202
|
+
dicio_step: "",
|
|
1203
|
+
secondname: "",
|
|
1204
|
+
nationality: "",
|
|
1205
|
+
seller_name: "",
|
|
1206
|
+
down_payment: "",
|
|
1207
|
+
municipality: "",
|
|
1208
|
+
score_no_hit: "",
|
|
1209
|
+
study_degree: "",
|
|
1210
|
+
branch_office: "",
|
|
1211
|
+
identity_data: "",
|
|
1212
|
+
interest_rate: "",
|
|
1213
|
+
score_interno: "",
|
|
1214
|
+
marital_status: "",
|
|
1215
|
+
monthly_income: "",
|
|
1216
|
+
motherlastname: "",
|
|
1217
|
+
score_rcc_fico: "",
|
|
1218
|
+
identity_selfie: "",
|
|
1219
|
+
amount_by_period: "",
|
|
1220
|
+
identity_id_back: "",
|
|
1221
|
+
proof_of_address: "",
|
|
1222
|
+
identity_id_front: "",
|
|
1223
|
+
economic_dependents: "",
|
|
1224
|
+
identity_id_request: "",
|
|
1225
|
+
identity_verification: "",
|
|
1226
|
+
is_address_ine_currently_live: "",
|
|
1227
|
+
fotografia_del_cliente_con_el_equipo: "",
|
|
1228
|
+
estado: "",
|
|
1229
|
+
gender: ""
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* Base customer for create customer with DynamiCore provider
|
|
1233
|
+
* */
|
|
1234
|
+
const cIDCCustomer = {
|
|
1235
|
+
pii: cIDCDataPii,
|
|
1236
|
+
client_type: 662
|
|
1237
|
+
};
|
|
1238
|
+
const cIDCPayment = {
|
|
1239
|
+
operation: 98,
|
|
1240
|
+
account: "",
|
|
1241
|
+
date: "",
|
|
1242
|
+
amount: 0,
|
|
1243
|
+
dst_account: "",
|
|
1244
|
+
reference: ""
|
|
1245
|
+
};
|
|
1246
|
+
const cIDCCharge = {
|
|
1247
|
+
barcode_url: "",
|
|
1248
|
+
currency: "",
|
|
1249
|
+
expires_at: 0,
|
|
1250
|
+
object: "",
|
|
1251
|
+
quantity: 0,
|
|
1252
|
+
reference: "",
|
|
1253
|
+
service_name: "",
|
|
1254
|
+
store_name: "",
|
|
1255
|
+
type: "",
|
|
1256
|
+
unit_price: 0
|
|
1257
|
+
};
|
|
1258
|
+
const cIDCGeneratedReference = {
|
|
1259
|
+
account: 0,
|
|
1260
|
+
active: 0,
|
|
1261
|
+
amount: 0,
|
|
1262
|
+
channel: "",
|
|
1263
|
+
charge: cIDCCharge,
|
|
1264
|
+
company: 0,
|
|
1265
|
+
id: "",
|
|
1266
|
+
operation: 0
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
* Common Factory Dynamic
|
|
1270
|
+
* */
|
|
1271
|
+
class FactoryDynamiCore {
|
|
1272
|
+
static CreateReferenceBody(client, contract, dateTime) {
|
|
1273
|
+
const customerInfo = {
|
|
1274
|
+
name: client.name,
|
|
1275
|
+
email: client.email,
|
|
1276
|
+
phone: client.phone,
|
|
1277
|
+
};
|
|
1278
|
+
const customerItems = {
|
|
1279
|
+
name: "Referencia Oxxo",
|
|
1280
|
+
unit_price: contract.financial.weeklyPayment,
|
|
1281
|
+
quantity: 1
|
|
1282
|
+
};
|
|
1283
|
+
const paymentMethod = {
|
|
1284
|
+
type: "oxxo_cash"
|
|
1285
|
+
};
|
|
1286
|
+
if (!client.dynamic_account)
|
|
1287
|
+
return null;
|
|
1288
|
+
const body = {
|
|
1289
|
+
id: client.id,
|
|
1290
|
+
data: {
|
|
1291
|
+
account: Number(client.dynamic_account),
|
|
1292
|
+
operation: 98,
|
|
1293
|
+
customer_info: customerInfo,
|
|
1294
|
+
items: customerItems,
|
|
1295
|
+
payment_method: paymentMethod
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
if (dateTime != undefined)
|
|
1299
|
+
body.date = dateTime;
|
|
1300
|
+
return body;
|
|
1301
|
+
}
|
|
1302
|
+
static CreateEmptyCustomer() {
|
|
1303
|
+
return cIDCCustomer;
|
|
1304
|
+
}
|
|
1305
|
+
static CreateCustomerFromOClient(client, contract) {
|
|
1306
|
+
const o = cIDCCustomer;
|
|
1307
|
+
o.pii.email = client.email;
|
|
1308
|
+
o.pii.name = client.name;
|
|
1309
|
+
o.pii.curp = client.curp;
|
|
1310
|
+
o.pii.phone = client.phone;
|
|
1311
|
+
o.pii.amount = String(contract.financial.total);
|
|
1312
|
+
o.pii.financed = String(contract.financial.financed);
|
|
1313
|
+
o.pii.amount_by_period = String(contract.financial.weeklyPayment);
|
|
1314
|
+
o.pii.zipcode = contract.address.zip;
|
|
1315
|
+
o.pii.street = contract.address.street;
|
|
1316
|
+
o.pii.city = contract.address.city;
|
|
1317
|
+
o.pii.state = contract.address.state;
|
|
1318
|
+
o.pii.colony = contract.address.neighbor;
|
|
1319
|
+
o.pii.num_ext = contract.address.ext;
|
|
1320
|
+
return o;
|
|
1321
|
+
}
|
|
1322
|
+
static CreateDynamicCredit(client, contract, clientDynamic) {
|
|
1323
|
+
const properties = {
|
|
1324
|
+
start_date: "",
|
|
1325
|
+
principal_disbursed: 0,
|
|
1326
|
+
expected_disbursed: 0,
|
|
1327
|
+
amount_commission_opening: 0
|
|
1328
|
+
};
|
|
1329
|
+
const config = {
|
|
1330
|
+
contract: `FP-${client.name}`,
|
|
1331
|
+
credit_type: "Arrendamiento",
|
|
1332
|
+
interest_rate: 528,
|
|
1333
|
+
installments: 0,
|
|
1334
|
+
periodicity: "WEEK",
|
|
1335
|
+
interest_base: "ACT/ACT",
|
|
1336
|
+
commission_opening: 40,
|
|
1337
|
+
financed_amount: contract.financial.financed,
|
|
1338
|
+
interest_arrears: 0
|
|
1339
|
+
};
|
|
1340
|
+
if (!client.dynamic_account)
|
|
1341
|
+
return null;
|
|
1342
|
+
return {
|
|
1343
|
+
id: Number(client.dynamic_account),
|
|
1344
|
+
group: clientDynamic.group,
|
|
1345
|
+
company: clientDynamic.company,
|
|
1346
|
+
client: clientDynamic.id,
|
|
1347
|
+
created_at: "",
|
|
1348
|
+
currency: "484",
|
|
1349
|
+
status: "pending",
|
|
1350
|
+
properties: properties,
|
|
1351
|
+
product: 1756,
|
|
1352
|
+
enabled: "1",
|
|
1353
|
+
config: config,
|
|
1354
|
+
amount: 0,
|
|
1355
|
+
type: "liabilities",
|
|
1356
|
+
identifier: null,
|
|
1357
|
+
start_at: null
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
static CreatePayment(contract, clientDynamic) {
|
|
1361
|
+
return {
|
|
1362
|
+
account: String(clientDynamic.id),
|
|
1363
|
+
amount: contract.financial.weeklyPayment,
|
|
1364
|
+
date: "",
|
|
1365
|
+
dst_account: String(clientDynamic.id),
|
|
1366
|
+
external_id: "",
|
|
1367
|
+
extras: {},
|
|
1368
|
+
operation: 98,
|
|
1369
|
+
reference: ""
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
static getNextDateTime() {
|
|
1373
|
+
const now = new Date();
|
|
1374
|
+
const nextDateTime = new Date(now.getTime() + 1000); // Add 1 second as an example
|
|
1375
|
+
const year = nextDateTime.getFullYear();
|
|
1376
|
+
const month = String(nextDateTime.getMonth() + 1).padStart(2, '0');
|
|
1377
|
+
const day = String(nextDateTime.getDate()).padStart(2, '0');
|
|
1378
|
+
const hours = String(nextDateTime.getHours()).padStart(2, '0');
|
|
1379
|
+
const minutes = String(nextDateTime.getMinutes()).padStart(2, '0');
|
|
1380
|
+
const seconds = String(nextDateTime.getSeconds()).padStart(2, '0');
|
|
1381
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
|
|
1382
|
+
}
|
|
1383
|
+
static getIsoDate() {
|
|
1384
|
+
const now = new Date();
|
|
1385
|
+
return now.toISOString();
|
|
1386
|
+
}
|
|
1387
|
+
static FormPayment(contract, account) {
|
|
1388
|
+
let data = FactoryDynamiCore.CreatePayment(contract, account);
|
|
1389
|
+
return {
|
|
1390
|
+
amount: new UntypedFormControl(data.amount, [Validators.required, Validators.min(0)]),
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
var ePaymentType;
|
|
1396
|
+
(function (ePaymentType) {
|
|
1397
|
+
ePaymentType["OXXO"] = "OXXO";
|
|
1398
|
+
ePaymentType["ALTERNA"] = "ALTERNA";
|
|
1399
|
+
ePaymentType["OXXO_RECURRENT"] = "oxxo_recurrent";
|
|
1400
|
+
})(ePaymentType || (ePaymentType = {}));
|
|
1401
|
+
class FactoryConekta {
|
|
1402
|
+
static createOrder(client, contract, dateTime) {
|
|
1403
|
+
if (client.conekta_id == undefined)
|
|
1404
|
+
return {
|
|
1405
|
+
data: {
|
|
1406
|
+
charges: [],
|
|
1407
|
+
currency: "",
|
|
1408
|
+
customer_info: { customer_id: "" },
|
|
1409
|
+
line_items: []
|
|
1410
|
+
},
|
|
1411
|
+
id: ""
|
|
1412
|
+
};
|
|
1413
|
+
const customer_info = {
|
|
1414
|
+
customer_id: client.conekta_id
|
|
1415
|
+
};
|
|
1416
|
+
const week = ((3600 * 24) * 30) * 1000;
|
|
1417
|
+
let next = new Date().getTime() + week;
|
|
1418
|
+
next = Math.floor(next / 1000);
|
|
1419
|
+
const method = {
|
|
1420
|
+
type: "cash",
|
|
1421
|
+
expires_at: next,
|
|
1422
|
+
};
|
|
1423
|
+
const charge = {
|
|
1424
|
+
amount: contract.financial.weeklyPayment * 100,
|
|
1425
|
+
payment_method: method
|
|
1426
|
+
};
|
|
1427
|
+
const charges = [charge];
|
|
1428
|
+
const antifraud_info = {
|
|
1429
|
+
newKey: "Key"
|
|
1430
|
+
};
|
|
1431
|
+
const lineItem = {
|
|
1432
|
+
antifraud_info: antifraud_info,
|
|
1433
|
+
name: `Referencia credito ${client.name}`,
|
|
1434
|
+
quantity: 1,
|
|
1435
|
+
unit_price: contract.financial.weeklyPayment * 100,
|
|
1436
|
+
};
|
|
1437
|
+
const lineItems = [lineItem];
|
|
1438
|
+
const orderData = {
|
|
1439
|
+
customer_info: customer_info,
|
|
1440
|
+
charges: charges,
|
|
1441
|
+
currency: "MXN",
|
|
1442
|
+
line_items: lineItems
|
|
1443
|
+
};
|
|
1444
|
+
const order = {
|
|
1445
|
+
data: orderData,
|
|
1446
|
+
id: client.id
|
|
1447
|
+
};
|
|
1448
|
+
if (dateTime != undefined)
|
|
1449
|
+
order.date = dateTime;
|
|
1450
|
+
return order;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
// '
|
|
1454
|
+
// {
|
|
1455
|
+
// "customer_info": {
|
|
1456
|
+
// "name": "DevTest",
|
|
1457
|
+
// "email": "test@femsa.com",
|
|
1458
|
+
// "phone": "5522997233"
|
|
1459
|
+
// },
|
|
1460
|
+
// "currency": "MXN",
|
|
1461
|
+
// "line_items": [
|
|
1462
|
+
// {
|
|
1463
|
+
// "name": "Box of Cohiba S1s",
|
|
1464
|
+
// "quantity": 1,
|
|
1465
|
+
// "unit_price": 20000
|
|
1466
|
+
// }
|
|
1467
|
+
// ]
|
|
1468
|
+
// }
|
|
1469
|
+
// '
|
|
1470
|
+
|
|
1471
|
+
const ROUTE_NOTIFICATIONS = "notifications";
|
|
1472
|
+
const ROUTE_GLOBAL_REFERENCE2 = "/contract-reference";
|
|
1473
|
+
const prodFunction = "https://us-central1-ravcredit-2b079.cloudfunctions.net/CustomerNotification";
|
|
1474
|
+
const prodFunction2 = "https://customernotification-2imgfxveka-uc.a.run.app";
|
|
1475
|
+
const localTest = "http://127.0.0.1:5001/ravcredit-2b079/us-central1/CustomerNotification";
|
|
1476
|
+
const ravCreditFunctions = prodFunction;
|
|
1477
|
+
class FactoryNotification {
|
|
1478
|
+
static FormNotification(notification) {
|
|
1479
|
+
let data = cNotification;
|
|
1480
|
+
if (notification)
|
|
1481
|
+
data = notification;
|
|
1482
|
+
return {
|
|
1483
|
+
title: new UntypedFormControl(data.notification.title, [Validators.required, Validators.min(1)]),
|
|
1484
|
+
body: new UntypedFormControl(data.notification.body, [Validators.required, Validators.min(1)]),
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
static CreateGlobalNotificationObj(data) {
|
|
1488
|
+
const o = {};
|
|
1489
|
+
if (data.notification) {
|
|
1490
|
+
const not = {};
|
|
1491
|
+
if (data.notification.body)
|
|
1492
|
+
not["body"] = data.notification.body;
|
|
1493
|
+
if (data.notification.title)
|
|
1494
|
+
not["title"] = data.notification.title;
|
|
1495
|
+
if (data.ids)
|
|
1496
|
+
not["ids"] = data.ids;
|
|
1497
|
+
if (data.tokens)
|
|
1498
|
+
not["tokens"] = data.tokens;
|
|
1499
|
+
if (data.type)
|
|
1500
|
+
not["type"] = data.type;
|
|
1501
|
+
if (data.data)
|
|
1502
|
+
if (data.data.route)
|
|
1503
|
+
not["route"] = data.data.route;
|
|
1504
|
+
o["data"] = not;
|
|
1505
|
+
}
|
|
1506
|
+
return o;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
const keyUserID = "rc_uid";
|
|
1511
|
+
const dbVersion = 1;
|
|
1512
|
+
const dbName = "RavCreditDB";
|
|
1513
|
+
const keyPathId = "id";
|
|
1514
|
+
const dbAuthStore = "authStore";
|
|
1515
|
+
const dbUsersStore = "usersStore";
|
|
1516
|
+
const dbContractsStore = "contractsStore";
|
|
1517
|
+
const dbClientsStore = "clientsStore";
|
|
1518
|
+
const dbBusinessInfo = "businessInfo";
|
|
1519
|
+
const dbBusinessConfig = "businessConfig";
|
|
1520
|
+
const dbConektaClientsStore = "conektaClientsStore";
|
|
1521
|
+
const dbConektaReferencesStore = "conektaReferencesStore";
|
|
1522
|
+
const dbPassportReferencesStore = "passportReferencesStore";
|
|
1523
|
+
const dbDynamicReferencesStore = "dynamicReferencesStore";
|
|
1524
|
+
const dbDynamicAccountStore = "dynamicAccountStore";
|
|
1525
|
+
const dbNotificationsStore = "notificationsStore";
|
|
1526
|
+
const dbPaymentsStore = "paymentsStore";
|
|
1527
|
+
const dbIndexAuth = "iAuth";
|
|
1528
|
+
const dbIndexUsers = "iUsers";
|
|
1529
|
+
const dbIndexContracts = "iContracts";
|
|
1530
|
+
const dbIndexClients = "iClients";
|
|
1531
|
+
const dbIndexBusiness = "iBusiness";
|
|
1532
|
+
const dbIndexConektaClients = "iConecktaClients";
|
|
1533
|
+
const dbIndexConektaClientsRef = "iConecktaClientsRef";
|
|
1534
|
+
const dbIndexPassportClientsRef = "iPassportClientsRef";
|
|
1535
|
+
const dbIndexNotification = "iNotification";
|
|
1536
|
+
const dbIndexPayments = "iNotification";
|
|
1537
|
+
const dateFormat = "EEEE, dd MMM yyyy";
|
|
1538
|
+
const dateCompleteFormat = "EEEE, dd MMM yyyy hh:mm aaaa";
|
|
1539
|
+
const timeFormat = "hh:mm aaaa";
|
|
1540
|
+
const expiredPayment = "expiredPayment";
|
|
1541
|
+
|
|
1542
|
+
class IndexedDbService {
|
|
1543
|
+
indexDbStatus = false;
|
|
1544
|
+
iDb;
|
|
1545
|
+
constructor() {
|
|
1546
|
+
}
|
|
1547
|
+
// async dbAuthorization() {
|
|
1548
|
+
// // const k = this.getLocalUser()
|
|
1549
|
+
// // if (k == null) return false
|
|
1550
|
+
// //
|
|
1551
|
+
// // const db = await openDB(dbName, dbVersion)
|
|
1552
|
+
// // // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1553
|
+
// // const auth = await db.get(dbAuthStore, k)
|
|
1554
|
+
// // // utils auth = await store.get(k)
|
|
1555
|
+
// // db.close()
|
|
1556
|
+
//
|
|
1557
|
+
// let auth: any = null
|
|
1558
|
+
// return auth;
|
|
1559
|
+
//
|
|
1560
|
+
// }
|
|
1561
|
+
/****************** SIMPLE Transactional - CRUD *************************************/
|
|
1562
|
+
async dbGetObject(store, data) {
|
|
1563
|
+
if (!data)
|
|
1564
|
+
return data;
|
|
1565
|
+
const db = await openDB(dbName, dbVersion);
|
|
1566
|
+
return await db.get(store, data);
|
|
1567
|
+
}
|
|
1568
|
+
async dbGetAllByStore(store, index) {
|
|
1569
|
+
const db = await openDB(dbName, dbVersion);
|
|
1570
|
+
return await db.getAll(store);
|
|
1571
|
+
}
|
|
1572
|
+
async dbAddObject(store, data) {
|
|
1573
|
+
try {
|
|
1574
|
+
const db = await openDB(dbName, dbVersion);
|
|
1575
|
+
await db.put(store, data);
|
|
1576
|
+
return true;
|
|
1577
|
+
}
|
|
1578
|
+
catch (e) {
|
|
1579
|
+
return false;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
async dbRemoveObject(store, data) {
|
|
1583
|
+
const db = await openDB(dbName, dbVersion);
|
|
1584
|
+
return await db.delete(store, data);
|
|
1585
|
+
}
|
|
1586
|
+
/************************************* AUTH **************************************/
|
|
1587
|
+
async dbSignIn(store, data) {
|
|
1588
|
+
await this.iDb.put(store, data);
|
|
1589
|
+
const _data = data;
|
|
1590
|
+
this.setLocalStorage(keyUserID, _data.id);
|
|
1591
|
+
}
|
|
1592
|
+
async dbSignOut() {
|
|
1593
|
+
const k = this.getLocalUser();
|
|
1594
|
+
if (!k)
|
|
1595
|
+
return;
|
|
1596
|
+
await this.iDb.delete(dbAuthStore, k);
|
|
1597
|
+
this.removeLocalStorage(keyUserID);
|
|
1598
|
+
}
|
|
1599
|
+
async dbAuthorization() {
|
|
1600
|
+
const k = this.getLocalUser();
|
|
1601
|
+
if (k == null)
|
|
1602
|
+
return false;
|
|
1603
|
+
const db = await openDB(dbName, dbVersion);
|
|
1604
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1605
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1606
|
+
// utils auth = await store.get(k)
|
|
1607
|
+
db.close();
|
|
1608
|
+
if (!auth)
|
|
1609
|
+
return false;
|
|
1610
|
+
else
|
|
1611
|
+
return true;
|
|
1612
|
+
}
|
|
1613
|
+
async dbGetToken() {
|
|
1614
|
+
const k = this.getLocalUser();
|
|
1615
|
+
if (k == null)
|
|
1616
|
+
return "";
|
|
1617
|
+
const db = await openDB(dbName, dbVersion);
|
|
1618
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1619
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1620
|
+
// utils auth = await store.get(k)
|
|
1621
|
+
db.close();
|
|
1622
|
+
return auth.access_token != "" ? auth.access_token : "";
|
|
1623
|
+
}
|
|
1624
|
+
/******************************** Local Storage *************************************/
|
|
1625
|
+
setLocalStorage(k, v) {
|
|
1626
|
+
localStorage.setItem(k, v);
|
|
1627
|
+
}
|
|
1628
|
+
getLocalStorage(k) {
|
|
1629
|
+
return localStorage.getItem(k);
|
|
1630
|
+
}
|
|
1631
|
+
removeLocalStorage(k) {
|
|
1632
|
+
return localStorage.removeItem(k);
|
|
1633
|
+
}
|
|
1634
|
+
getLocalUser() {
|
|
1635
|
+
const k = localStorage.getItem(keyUserID);
|
|
1636
|
+
return (k);
|
|
1637
|
+
}
|
|
1638
|
+
/********************************************************************************* **/
|
|
1639
|
+
async getPlatformUser() {
|
|
1640
|
+
const k = this.getLocalStorage(keyUserID);
|
|
1641
|
+
if (k == null)
|
|
1642
|
+
return "";
|
|
1643
|
+
const db = await openDB(dbName, dbVersion);
|
|
1644
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1645
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1646
|
+
// utils auth = await store.get(k)
|
|
1647
|
+
db.close();
|
|
1648
|
+
return auth.name != "" ? auth.name : "";
|
|
1649
|
+
}
|
|
1650
|
+
async getToken() {
|
|
1651
|
+
const k = this.getLocalUser();
|
|
1652
|
+
if (k == null)
|
|
1653
|
+
return "";
|
|
1654
|
+
const db = await openDB(dbName, dbVersion);
|
|
1655
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1656
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1657
|
+
// utils auth = await store.get(k)
|
|
1658
|
+
db.close();
|
|
1659
|
+
return auth.access_token != "" ? auth.access_token : "";
|
|
1660
|
+
}
|
|
1661
|
+
async addObject(store, data) {
|
|
1662
|
+
try {
|
|
1663
|
+
const db = await openDB(dbName, dbVersion);
|
|
1664
|
+
await db.put(store, data);
|
|
1665
|
+
return true;
|
|
1666
|
+
}
|
|
1667
|
+
catch (e) {
|
|
1668
|
+
return false;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
async patchObject(store, data) {
|
|
1672
|
+
try {
|
|
1673
|
+
const db = await openDB(dbName, dbVersion);
|
|
1674
|
+
const txn = db.transaction(store, "readwrite");
|
|
1675
|
+
const obj = txn.objectStore(store);
|
|
1676
|
+
// const index = obj.index(keyPathCurp)
|
|
1677
|
+
await obj.put(data);
|
|
1678
|
+
return data;
|
|
1679
|
+
}
|
|
1680
|
+
catch (e) {
|
|
1681
|
+
console.error(e);
|
|
1682
|
+
return {};
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
async updateObjectByID(store, id, data) {
|
|
1686
|
+
try {
|
|
1687
|
+
const db = await openDB(dbName, dbVersion);
|
|
1688
|
+
const res = await db.get(store, id);
|
|
1689
|
+
if (res != undefined)
|
|
1690
|
+
await this.removeObject(dbClientsStore, id);
|
|
1691
|
+
return await this.addObject(store, data);
|
|
1692
|
+
}
|
|
1693
|
+
catch (e) {
|
|
1694
|
+
console.error("updateObjectByID Catch Error:", e);
|
|
1695
|
+
return false;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
async upsertObjectById(store, id, data) {
|
|
1699
|
+
const db = await openDB(dbName, dbVersion);
|
|
1700
|
+
const res = await db.get(store, id);
|
|
1701
|
+
if (res)
|
|
1702
|
+
await this.removeObject(store, id);
|
|
1703
|
+
return await db.add(store, data);
|
|
1704
|
+
}
|
|
1705
|
+
async removeObject(store, data) {
|
|
1706
|
+
const db = await openDB(dbName, dbVersion);
|
|
1707
|
+
return await db.delete(store, data);
|
|
1708
|
+
}
|
|
1709
|
+
async deleteObjectByID(store, id) {
|
|
1710
|
+
try {
|
|
1711
|
+
const db = await openDB(dbName, dbVersion);
|
|
1712
|
+
const txn = db.transaction(store, "readwrite");
|
|
1713
|
+
const obj = txn.objectStore(store);
|
|
1714
|
+
const index = obj.index(keyPathId);
|
|
1715
|
+
const va2 = index.openCursor(id);
|
|
1716
|
+
va2.then(async (cursor) => {
|
|
1717
|
+
while (cursor) {
|
|
1718
|
+
cursor.delete();
|
|
1719
|
+
cursor = await cursor.continue();
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
return va2;
|
|
1723
|
+
}
|
|
1724
|
+
catch (e) {
|
|
1725
|
+
console.error(e);
|
|
1726
|
+
return {};
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
async cleanAll(store) {
|
|
1730
|
+
const db = await openDB(dbName, dbVersion);
|
|
1731
|
+
return await db.clear(store);
|
|
1732
|
+
}
|
|
1733
|
+
async getObject(store, data) {
|
|
1734
|
+
if (!data)
|
|
1735
|
+
return data;
|
|
1736
|
+
const db = await openDB(dbName, dbVersion);
|
|
1737
|
+
return await db.get(store, data);
|
|
1738
|
+
}
|
|
1739
|
+
async addBuildByStore(store, data) {
|
|
1740
|
+
for (const o of data) {
|
|
1741
|
+
const exists = await this.getObject(store, o["id"]);
|
|
1742
|
+
if (!exists)
|
|
1743
|
+
await this.addObject(store, o);
|
|
1744
|
+
else
|
|
1745
|
+
await this.updateObject(store, o);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
async updateObject(store, data) {
|
|
1749
|
+
const db = await openDB(dbName, dbVersion);
|
|
1750
|
+
await db.put(store, data);
|
|
1751
|
+
}
|
|
1752
|
+
async getAllByStore(store, index) {
|
|
1753
|
+
const db = await openDB(dbName, dbVersion);
|
|
1754
|
+
return await db.getAll(store);
|
|
1755
|
+
}
|
|
1756
|
+
async getAuthUser() {
|
|
1757
|
+
const data = await this.getAllByStore(dbAuthStore);
|
|
1758
|
+
return data[0];
|
|
1759
|
+
}
|
|
1760
|
+
async getAuthName() {
|
|
1761
|
+
const data = await this.getAuthUser();
|
|
1762
|
+
return data.name;
|
|
1763
|
+
}
|
|
1764
|
+
async getAuthUsername() {
|
|
1765
|
+
const data = await this.getAuthUser();
|
|
1766
|
+
return data.username;
|
|
1767
|
+
}
|
|
1768
|
+
async saveDataLocally(contract, client, providerData) {
|
|
1769
|
+
try {
|
|
1770
|
+
await this.addObject(dbClientsStore, client);
|
|
1771
|
+
await this.addObject(dbContractsStore, contract);
|
|
1772
|
+
if (!providerData)
|
|
1773
|
+
return false;
|
|
1774
|
+
if (contract.financial.provider === eProvider.Conekta) {
|
|
1775
|
+
await this.addObject(dbConektaClientsStore, providerData);
|
|
1776
|
+
await this.addObject(dbConektaReferencesStore, providerData);
|
|
1777
|
+
}
|
|
1778
|
+
else if (contract.financial.provider === eProvider.Passport) {
|
|
1779
|
+
await this.addObject(dbPassportReferencesStore, providerData);
|
|
1780
|
+
}
|
|
1781
|
+
else if (contract.financial.provider === eProvider.DynamiCore) {
|
|
1782
|
+
await this.addObject(dbDynamicReferencesStore, providerData);
|
|
1783
|
+
}
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
catch (e) {
|
|
1787
|
+
console.error(e);
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
/******************** MERGE **************************************/
|
|
1792
|
+
async getAllClientContracts() {
|
|
1793
|
+
const clientContract = [];
|
|
1794
|
+
const clients = await this.getAllByStore(dbClientsStore);
|
|
1795
|
+
if (clients.length == 0)
|
|
1796
|
+
return [];
|
|
1797
|
+
for (let client of clients) {
|
|
1798
|
+
const contract = await this.getObject(dbContractsStore, client.contract);
|
|
1799
|
+
const e = { ...client, ...contract };
|
|
1800
|
+
// preserve the id value over concat models
|
|
1801
|
+
e.id = client.id;
|
|
1802
|
+
e.status = client.status;
|
|
1803
|
+
clientContract.push(e);
|
|
1804
|
+
}
|
|
1805
|
+
return clientContract;
|
|
1806
|
+
}
|
|
1807
|
+
/******************** MERGE **************************************/
|
|
1808
|
+
async dbGetAllClientContracts() {
|
|
1809
|
+
const clientContract = [];
|
|
1810
|
+
const clients = await this.dbGetAllByStore(dbClientsStore);
|
|
1811
|
+
if (clients.length == 0)
|
|
1812
|
+
return [];
|
|
1813
|
+
for (let client of clients) {
|
|
1814
|
+
const contract = await this.dbGetObject(dbContractsStore, client.contract);
|
|
1815
|
+
const e = { ...client, ...contract };
|
|
1816
|
+
// preserve the id value over concat models
|
|
1817
|
+
e.id = client.id;
|
|
1818
|
+
e.status = client.status;
|
|
1819
|
+
clientContract.push(e);
|
|
1820
|
+
}
|
|
1821
|
+
return clientContract;
|
|
1822
|
+
}
|
|
1823
|
+
/****************** BUSINESS INFO *************************************/
|
|
1824
|
+
async getBusinessInfo() {
|
|
1825
|
+
const config = await this.dbGetAllByStore(dbBusinessInfo);
|
|
1826
|
+
if (!config)
|
|
1827
|
+
return null;
|
|
1828
|
+
return config[0];
|
|
1829
|
+
}
|
|
1830
|
+
/****************** BUSINESS CONFIG ************************************/
|
|
1831
|
+
async getBusinessConfig() {
|
|
1832
|
+
const config = await this.dbGetAllByStore(dbBusinessConfig);
|
|
1833
|
+
if (!config)
|
|
1834
|
+
return null;
|
|
1835
|
+
return config[0];
|
|
1836
|
+
}
|
|
1837
|
+
async updateBusinessConfig(config) {
|
|
1838
|
+
// config.version = "1.0"
|
|
1839
|
+
await this.dbRemoveObject(dbBusinessConfig, "1.0");
|
|
1840
|
+
await this.dbAddObject(dbBusinessConfig, config);
|
|
1841
|
+
}
|
|
1842
|
+
async updateBusinessInfo(config) {
|
|
1843
|
+
config.version = "v2024";
|
|
1844
|
+
await this.dbRemoveObject(dbBusinessInfo, "v2024");
|
|
1845
|
+
await this.dbAddObject(dbBusinessInfo, config);
|
|
1846
|
+
}
|
|
1847
|
+
/**************** NOTIFICATIONS *********************************/
|
|
1848
|
+
async getLocalNotifications() {
|
|
1849
|
+
const notifications = await this.dbGetAllByStore(dbNotificationsStore);
|
|
1850
|
+
if (!notifications)
|
|
1851
|
+
return null;
|
|
1852
|
+
return notifications;
|
|
1853
|
+
}
|
|
1854
|
+
async updateNotifications(notifications) {
|
|
1855
|
+
for (const o of notifications) {
|
|
1856
|
+
const exists = await this.dbGetObject(dbNotificationsStore, o.notification_id);
|
|
1857
|
+
if (!exists) {
|
|
1858
|
+
await this.dbAddObject(dbNotificationsStore, o);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1863
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, providedIn: 'root' });
|
|
1864
|
+
}
|
|
1865
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, decorators: [{
|
|
1866
|
+
type: Injectable,
|
|
1867
|
+
args: [{
|
|
1868
|
+
providedIn: 'root'
|
|
1869
|
+
}]
|
|
1870
|
+
}], ctorParameters: () => [] });
|
|
1871
|
+
|
|
1872
|
+
class UtilTime {
|
|
1873
|
+
localeFns = es;
|
|
1874
|
+
static IsExpired(time) {
|
|
1875
|
+
const dateInit = new Date(time);
|
|
1876
|
+
const dayInit = dateInit.getDate();
|
|
1877
|
+
const monthInit = dateInit.getMonth() + 1;
|
|
1878
|
+
const dateActual = new Date();
|
|
1879
|
+
const dayActual = dateActual.getDate();
|
|
1880
|
+
const monthActual = dateActual.getMonth() + 1;
|
|
1881
|
+
if (monthActual > monthInit)
|
|
1882
|
+
return true;
|
|
1883
|
+
return dayActual > dayInit;
|
|
1884
|
+
}
|
|
1885
|
+
static getDates(initial, weeks) {
|
|
1886
|
+
const dates = [];
|
|
1887
|
+
let prev = initial;
|
|
1888
|
+
for (let i = 0; i < weeks; i++) {
|
|
1889
|
+
const date = add(prev, { weeks: 1 });
|
|
1890
|
+
dates.push({
|
|
1891
|
+
week: i + 1,
|
|
1892
|
+
date: date.getTime()
|
|
1893
|
+
});
|
|
1894
|
+
prev = date.getTime();
|
|
1895
|
+
}
|
|
1896
|
+
return dates;
|
|
1897
|
+
}
|
|
1898
|
+
static getPreviousWeek() {
|
|
1899
|
+
const today = new Date().getTime();
|
|
1900
|
+
const week = ((3600 * 24) * 7) * 1000;
|
|
1901
|
+
return today - week;
|
|
1902
|
+
}
|
|
1903
|
+
static getDayNum(date) {
|
|
1904
|
+
return getDate(date);
|
|
1905
|
+
}
|
|
1906
|
+
static getDayName(date) {
|
|
1907
|
+
return format(date, "EEEE", { locale: es });
|
|
1908
|
+
}
|
|
1909
|
+
static getMonthName(date) {
|
|
1910
|
+
return format(date, "MMMM", { locale: es }).toUpperCase();
|
|
1911
|
+
}
|
|
1912
|
+
static getYear(date) {
|
|
1913
|
+
return format(date, "yyyy");
|
|
1914
|
+
}
|
|
1915
|
+
static GetNextPayment(time, provider) {
|
|
1916
|
+
let week = 0;
|
|
1917
|
+
if (provider == eProvider.Conekta) {
|
|
1918
|
+
week = (((3600 * 24) * 7));
|
|
1919
|
+
}
|
|
1920
|
+
else if (provider == eProvider.DynamiCore) {
|
|
1921
|
+
week = (((3600 * 24) * 7) * 1000);
|
|
1922
|
+
}
|
|
1923
|
+
return this.getLocalTimeFromLong(time + week, provider);
|
|
1924
|
+
}
|
|
1925
|
+
static getLocalTimeFromLong(time, provider) {
|
|
1926
|
+
if (time <= 0)
|
|
1927
|
+
return "";
|
|
1928
|
+
let factor = this.GetFactor(provider);
|
|
1929
|
+
let dateTime = time * factor;
|
|
1930
|
+
let parsedDate = format(new Date(dateTime), dateFormat, {
|
|
1931
|
+
locale: es
|
|
1932
|
+
});
|
|
1933
|
+
return parsedDate;
|
|
1934
|
+
}
|
|
1935
|
+
static DelayPaymentLast(lastPayment, provider, injector) {
|
|
1936
|
+
let factor = this.GetFactor(provider);
|
|
1937
|
+
let now = new Date().getTime();
|
|
1938
|
+
let last = 0;
|
|
1939
|
+
if (provider == eProvider.Conekta)
|
|
1940
|
+
last = ((((3600 * 24) * 7)) + lastPayment) * factor;
|
|
1941
|
+
else if (provider == eProvider.DynamiCore)
|
|
1942
|
+
last = ((((3600 * 24) * 7) * 1000) + lastPayment) * factor;
|
|
1943
|
+
runInInjectionContext(injector, () => {
|
|
1944
|
+
const idb = inject(IndexedDbService);
|
|
1945
|
+
// const observable = inject(ObservablesService)
|
|
1946
|
+
idb.setLocalStorage(expiredPayment, String(now > last));
|
|
1947
|
+
// observable.isLate.next(now > last)
|
|
1948
|
+
});
|
|
1949
|
+
// 1751091565767
|
|
1950
|
+
// 1751557440
|
|
1951
|
+
return now > last;
|
|
1952
|
+
}
|
|
1953
|
+
static GetFactor(provider) {
|
|
1954
|
+
let factor = 1;
|
|
1955
|
+
if (provider == eProvider.Conekta)
|
|
1956
|
+
factor = 1000;
|
|
1957
|
+
return factor;
|
|
1958
|
+
}
|
|
1959
|
+
static GetEpochFromFormatedDate(date) {
|
|
1960
|
+
if (date == "")
|
|
1961
|
+
return 0;
|
|
1962
|
+
const _date = new Date(date);
|
|
1963
|
+
if (isNaN(_date.getTime()))
|
|
1964
|
+
return 0;
|
|
1965
|
+
return _date.getTime();
|
|
1966
|
+
}
|
|
1967
|
+
static GetTimeFromString(date) {
|
|
1968
|
+
return format(new Date(date), timeFormat, {
|
|
1969
|
+
locale: es
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
static GetDateFromString(date) {
|
|
1973
|
+
return format(new Date(date), dateCompleteFormat, {
|
|
1974
|
+
locale: es
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
// Quick sort
|
|
1978
|
+
static SortingByTime(payments) {
|
|
1979
|
+
if (payments.length <= 1)
|
|
1980
|
+
return payments;
|
|
1981
|
+
const pivot = payments[payments.length - 1];
|
|
1982
|
+
const pivotDate = new Date(pivot.created).getTime();
|
|
1983
|
+
const left = [];
|
|
1984
|
+
const right = [];
|
|
1985
|
+
for (let i = 0; i < payments.length - 1; i++) {
|
|
1986
|
+
const actualDate = new Date(payments[i].created).getTime();
|
|
1987
|
+
if (actualDate > pivotDate)
|
|
1988
|
+
left.push(payments[i]);
|
|
1989
|
+
else
|
|
1990
|
+
right.push(payments[i]);
|
|
1991
|
+
}
|
|
1992
|
+
return [...this.SortingByTime(left), pivot, ...this.SortingByTime(right)];
|
|
1993
|
+
}
|
|
1994
|
+
static SortingByTimeConekta(payments) {
|
|
1995
|
+
if (payments.length <= 1)
|
|
1996
|
+
return payments;
|
|
1997
|
+
const pivot = payments[payments.length - 1];
|
|
1998
|
+
let pivotDate = 0;
|
|
1999
|
+
if (pivot.charges.data == undefined)
|
|
2000
|
+
return payments;
|
|
2001
|
+
if (pivot.charges.data[0].paid_at != undefined) {
|
|
2002
|
+
pivotDate = pivot.charges.data[0].paid_at;
|
|
2003
|
+
}
|
|
2004
|
+
else {
|
|
2005
|
+
pivot.charges.data[0].created_at;
|
|
2006
|
+
}
|
|
2007
|
+
if (pivotDate <= 0)
|
|
2008
|
+
return payments;
|
|
2009
|
+
const left = [];
|
|
2010
|
+
const right = [];
|
|
2011
|
+
for (let i = 0; i < payments.length - 1; i++) {
|
|
2012
|
+
const actual = payments[i].charges.data[0].paid_at;
|
|
2013
|
+
if (actual <= 0)
|
|
2014
|
+
continue;
|
|
2015
|
+
if (actual > pivotDate)
|
|
2016
|
+
left.push(payments[i]);
|
|
2017
|
+
else
|
|
2018
|
+
right.push(payments[i]);
|
|
2019
|
+
}
|
|
2020
|
+
return [...this.SortingByTimeConekta(left), pivot, ...this.SortingByTimeConekta(right)];
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
const cContractMetrics = {
|
|
2025
|
+
total: 0,
|
|
2026
|
+
activated: 0,
|
|
2027
|
+
paused: 0,
|
|
2028
|
+
completed: 0,
|
|
2029
|
+
canceled: 0,
|
|
2030
|
+
late: 0,
|
|
2031
|
+
conektaCount: 0,
|
|
2032
|
+
dynamicCount: 0,
|
|
2033
|
+
passportCount: 0,
|
|
2034
|
+
rateTotal: 0,
|
|
2035
|
+
rateActive: 0,
|
|
2036
|
+
ratePaused: 0,
|
|
2037
|
+
rateComplete: 0,
|
|
2038
|
+
rateCanceled: 0,
|
|
2039
|
+
rateLate: 0
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
class FactoryPassport {
|
|
2043
|
+
static CreatePassportReference(client, contract, dateTime) {
|
|
2044
|
+
const o = {
|
|
2045
|
+
passport: {
|
|
2046
|
+
type: ePassportTypes.CREATE,
|
|
2047
|
+
data: {
|
|
2048
|
+
name: client.name,
|
|
2049
|
+
email: client.email,
|
|
2050
|
+
amount: contract.financial.weeklyPayment,
|
|
2051
|
+
expirationDate: "",
|
|
2052
|
+
additional: {
|
|
2053
|
+
client: client.name,
|
|
2054
|
+
clientID: client.id,
|
|
2055
|
+
credit: client.status
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
contract: contract,
|
|
2060
|
+
date: dateTime
|
|
2061
|
+
};
|
|
2062
|
+
if (dateTime != undefined)
|
|
2063
|
+
o.date = dateTime;
|
|
2064
|
+
return o;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
class FactoryPayment {
|
|
2069
|
+
static CreatePayment(data, provider) {
|
|
2070
|
+
const o = {};
|
|
2071
|
+
if (provider == eProvider.DynamiCore)
|
|
2072
|
+
o.dynamicPayment = data;
|
|
2073
|
+
if (provider == eProvider.Conekta)
|
|
2074
|
+
o.conektaPayment = data;
|
|
2075
|
+
return o;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
/*
|
|
2080
|
+
* Public API Surface of ravcredit-lib
|
|
2081
|
+
*/
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* Generated bundle index. Do not edit.
|
|
2085
|
+
*/
|
|
2086
|
+
|
|
2087
|
+
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, eVerificationChannel, eVerificationStatus, eVerificationStep, expiredPayment, keyPathId, keyUserID, ravCreditFunctions, snackBarConfigAction, snackBarConfigNoAction, timeFormat, week };
|
|
2088
|
+
//# sourceMappingURL=ravcredit-lib.mjs.map
|