ravcredit-lib 0.0.26 → 0.0.27
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/ng-package.json +7 -0
- package/package.json +14 -25
- package/src/index.d.ts +60 -0
- package/src/lib/ravcredit-lib.component.spec.ts +23 -0
- package/src/lib/ravcredit-lib.component.ts +16 -0
- package/src/lib/ravcredit-lib.service.spec.ts +16 -0
- package/src/lib/ravcredit-lib.service.ts +9 -0
- package/src/lib/v1/const/constants.ts +37 -0
- package/src/lib/v1/idb/idb.service.spec.ts +16 -0
- package/src/lib/v1/idb/indexed-db.service.ts +396 -0
- package/src/lib/v1/objects/oAddress.ts +9 -0
- package/src/lib/v1/objects/oBusiness.ts +93 -0
- package/src/lib/v1/objects/oClient.ts +46 -0
- package/src/lib/v1/objects/oConekta.ts +361 -0
- package/src/lib/v1/objects/oContract.ts +31 -0
- package/src/lib/v1/objects/oContractAll.ts +37 -0
- package/src/lib/v1/objects/oCustomer.ts +36 -0
- package/src/lib/v1/objects/oDevice.ts +5 -0
- package/src/lib/v1/objects/oFinancial.ts +32 -0
- package/src/lib/v1/objects/oLogIn.ts +26 -0
- package/src/lib/v1/objects/oNewPayment.ts +18 -0
- package/src/lib/v1/objects/oNotification.ts +33 -0
- package/src/lib/v1/objects/oPassport.ts +60 -0
- package/src/lib/v1/objects/oUser.ts +35 -0
- package/src/lib/v1/objects/oVerification.ts +79 -0
- package/src/lib/v1/util/UtilBusiness.ts +187 -0
- package/src/lib/v1/util/UtilClient.ts +300 -0
- package/src/lib/v1/util/UtilConekta.ts +97 -0
- package/src/lib/v1/util/UtilContract.ts +430 -0
- package/src/lib/v1/util/UtilDashboard.ts +19 -0
- package/src/lib/v1/util/UtilDynamiCore.ts +752 -0
- package/src/lib/v1/util/UtilNotification.ts +46 -0
- package/src/lib/v1/util/UtilPassport.ts +33 -0
- package/src/lib/v1/util/UtilPayment.ts +22 -0
- package/src/lib/v1/util/UtilTime.ts +179 -0
- package/src/lib/v1/util/UtilsHttp.ts +25 -0
- package/src/lib/v2/constant/constants.ts +125 -0
- package/src/lib/v2/constant/messages.ts +28 -0
- package/src/lib/v2/enum/EnumAsset.ts +4 -0
- package/src/lib/v2/enum/EnumAuth.ts +29 -0
- package/src/lib/v2/enum/EnumClient.ts +7 -0
- package/src/lib/v2/enum/EnumConekta.ts +14 -0
- package/src/lib/v2/enum/EnumDynamic.ts +8 -0
- package/src/lib/v2/enum/EnumNotification.ts +1 -0
- package/src/lib/v2/enum/EnumPassport.ts +4 -0
- package/src/lib/v2/enum/EnumPayment.ts +5 -0
- package/src/lib/v2/enum/EnumRoles.ts +7 -0
- package/src/lib/v2/enum/EnumToken.ts +11 -0
- package/src/lib/v2/enum/EnumUtil.ts +22 -0
- package/src/lib/v2/enum/EnumVerification.ts +22 -0
- package/src/lib/v2/objects/oAsset.ts +44 -0
- package/src/lib/v2/objects/oAws.ts +8 -0
- package/src/lib/v2/objects/oCatalog.ts +6 -0
- package/src/lib/v2/objects/oClient.ts +36 -0
- package/src/lib/v2/objects/oCompany.ts +10 -0
- package/src/lib/v2/objects/oContract.ts +10 -0
- package/src/lib/v2/objects/oHttp.ts +33 -0
- package/src/lib/v2/objects/oMediaDto.ts +10 -0
- package/src/lib/v2/objects/oMessaging.ts +10 -0
- package/src/lib/v2/objects/oScoreDto.ts +38 -0
- package/src/lib/v2/objects/oUtil.ts +68 -0
- package/src/public-api.ts +66 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/ravcredit-lib.mjs +0 -2182
- package/fesm2022/ravcredit-lib.mjs.map +0 -1
- package/index.d.ts +0 -1881
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const cTopic = "RavCreditClients"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface oNotificationResponses {
|
|
5
|
+
successCount: number,
|
|
6
|
+
failureCount: number,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface oNotification {
|
|
10
|
+
ids?: string[];
|
|
11
|
+
type?: string,
|
|
12
|
+
tokens?: string[],
|
|
13
|
+
topic?: string,
|
|
14
|
+
notification: {
|
|
15
|
+
title: string,
|
|
16
|
+
body: string
|
|
17
|
+
},
|
|
18
|
+
data: any,
|
|
19
|
+
notification_id?: number,
|
|
20
|
+
recipient?: string,
|
|
21
|
+
responses?: oNotificationResponses
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const cNotification: oNotification = {
|
|
25
|
+
notification: {
|
|
26
|
+
title: "",
|
|
27
|
+
body: ""
|
|
28
|
+
},
|
|
29
|
+
data: {
|
|
30
|
+
route: ""
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {oContract} from "./oContract";
|
|
2
|
+
|
|
3
|
+
/** *********************************************************************************/
|
|
4
|
+
export interface iPassportAdditional {
|
|
5
|
+
client?: string;
|
|
6
|
+
clientID?: string;
|
|
7
|
+
credit?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface iPassportReferenceData {
|
|
11
|
+
name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
amount: number;
|
|
14
|
+
expirationDate: string;
|
|
15
|
+
additional: iPassportAdditional;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Passport request interface base */
|
|
19
|
+
export interface iPassportReference {
|
|
20
|
+
type: string;
|
|
21
|
+
data: iPassportReferenceData;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Global passport reference aPI */
|
|
25
|
+
export interface iGlobalPassport {
|
|
26
|
+
passport: iPassportReference;
|
|
27
|
+
contract: oContract
|
|
28
|
+
date?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** ******************************** */
|
|
32
|
+
export interface iPassportResponseData {
|
|
33
|
+
name: string;
|
|
34
|
+
email: string;
|
|
35
|
+
amount: number;
|
|
36
|
+
expirationDate: string;
|
|
37
|
+
additional: iPassportAdditional;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface iPassportReferenceCenters {
|
|
41
|
+
name: string;
|
|
42
|
+
logo: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface iPassportReferenceRes {
|
|
46
|
+
reference: string
|
|
47
|
+
centers: iPassportReferenceCenters[],
|
|
48
|
+
centerId: number,
|
|
49
|
+
barcode: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Passport response interface base */
|
|
53
|
+
export interface iPassportResponse {
|
|
54
|
+
type: string;
|
|
55
|
+
data: iPassportResponseData;
|
|
56
|
+
message: string;
|
|
57
|
+
references: iPassportReference[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** ******************************** */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {WritableSignal} from "@angular/core";
|
|
2
|
+
import { eRoles } from "../../v2/enum/EnumRoles";
|
|
3
|
+
|
|
4
|
+
export interface iUser {
|
|
5
|
+
pUser: oUser
|
|
6
|
+
|
|
7
|
+
getAllUsers(): void
|
|
8
|
+
|
|
9
|
+
editUser(user: oUser): void
|
|
10
|
+
|
|
11
|
+
deleteUser(user: oUser): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface oUser {
|
|
15
|
+
id: string
|
|
16
|
+
username: string,
|
|
17
|
+
name: string,
|
|
18
|
+
password: string,
|
|
19
|
+
role: eRoles,
|
|
20
|
+
lastLogin?: number
|
|
21
|
+
createdAt?: number,
|
|
22
|
+
access_token: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface iServiceUser {
|
|
26
|
+
users: WritableSignal<oUser[]>
|
|
27
|
+
|
|
28
|
+
getAllUsersServer(): void
|
|
29
|
+
|
|
30
|
+
createUser(o: oUser): void
|
|
31
|
+
|
|
32
|
+
updateUser(o: oUser): void
|
|
33
|
+
|
|
34
|
+
deleteUser(id: string): void
|
|
35
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// export enum oGenVerificationProvider {
|
|
2
|
+
// pending, approved, expired
|
|
3
|
+
// }
|
|
4
|
+
//
|
|
5
|
+
// export interface oVerificationLookup {
|
|
6
|
+
// carrier: any[]
|
|
7
|
+
// }
|
|
8
|
+
//
|
|
9
|
+
// export interface oVerificationSenCodeAttempt {
|
|
10
|
+
// attempt_sid: any[],
|
|
11
|
+
// channel: any[],
|
|
12
|
+
// time: any[]
|
|
13
|
+
// }
|
|
14
|
+
//
|
|
15
|
+
// export interface oGenVerification {
|
|
16
|
+
// Sid: string
|
|
17
|
+
// ServiceSid: string,
|
|
18
|
+
// AccountSid: string,
|
|
19
|
+
// To: string,
|
|
20
|
+
// Channel: any,
|
|
21
|
+
// Status: oGenVerificationProvider,
|
|
22
|
+
// Valid: boolean,
|
|
23
|
+
// Lookup: oVerificationLookup,
|
|
24
|
+
// SendCodeAttempts: oVerificationSenCodeAttempt[],
|
|
25
|
+
// DateCreated: string,
|
|
26
|
+
// DateUpdated: string,
|
|
27
|
+
// Url: string
|
|
28
|
+
// }
|
|
29
|
+
//
|
|
30
|
+
// export interface oVerification {
|
|
31
|
+
// Sid : string,
|
|
32
|
+
// ServiceSid : string,
|
|
33
|
+
// AccountSid : string,
|
|
34
|
+
// To : string,
|
|
35
|
+
// Channel : any,
|
|
36
|
+
// Status : oGenVerificationProvider,
|
|
37
|
+
// Valid : boolean,
|
|
38
|
+
// DateCreated : string,
|
|
39
|
+
// DateUpdated : string
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
import {eVerificationChannel, eVerificationStatus} from '../../v2/enum/EnumVerification';
|
|
43
|
+
|
|
44
|
+
export interface ISendCodeAttempt {
|
|
45
|
+
time: string
|
|
46
|
+
channel: eVerificationChannel,
|
|
47
|
+
attemptSid : string,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IBaseVerification {
|
|
51
|
+
sid: string
|
|
52
|
+
service_sid:string
|
|
53
|
+
account_sid:string
|
|
54
|
+
to:string
|
|
55
|
+
channel: eVerificationChannel
|
|
56
|
+
status: eVerificationStatus
|
|
57
|
+
valid: boolean,
|
|
58
|
+
date_created: string
|
|
59
|
+
date_updated: string
|
|
60
|
+
amount: any,
|
|
61
|
+
payee: any,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IVerificationSms extends IBaseVerification {
|
|
65
|
+
lookup: any,
|
|
66
|
+
send_code_attempts: ISendCodeAttempt[],
|
|
67
|
+
sna: any,
|
|
68
|
+
url: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface IVerificationCheckSms
|
|
72
|
+
{
|
|
73
|
+
sna_attempts_error_codes: any[],
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface IVerificationData {
|
|
77
|
+
Phone?: string
|
|
78
|
+
VerificationCode?: string
|
|
79
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {UntypedFormArray, UntypedFormControl, Validators} from "@angular/forms";
|
|
2
|
+
import {
|
|
3
|
+
oBusinessConfig,
|
|
4
|
+
oBusinessDeadlines,
|
|
5
|
+
oBusinessInfo, oDaySchedule,
|
|
6
|
+
oSchedule,
|
|
7
|
+
oTmpBusinessConfig,
|
|
8
|
+
oWeekSchedule
|
|
9
|
+
} from "../objects/oBusiness";
|
|
10
|
+
import {oAddress} from '../objects/oAddress';
|
|
11
|
+
import {cAddress, cDaySchedule} from "../../v2/constant/constants";
|
|
12
|
+
|
|
13
|
+
export const cSchedule: oSchedule = {
|
|
14
|
+
day: "",
|
|
15
|
+
open: 0,
|
|
16
|
+
close: 0,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const cEmptyDay: oSchedule = {
|
|
20
|
+
close: 0, open: 0, day: ""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const week: string[] = [
|
|
24
|
+
"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
export const cDefinedSchedule: oSchedule[] = [
|
|
28
|
+
{close: 0, open: 0, day: "monday"},
|
|
29
|
+
{close: 0, open: 0, day: "tuesday"},
|
|
30
|
+
{close: 0, open: 0, day: "wednesday"},
|
|
31
|
+
{close: 0, open: 0, day: "thursday"},
|
|
32
|
+
{close: 0, open: 0, day: "friday"},
|
|
33
|
+
{close: 0, open: 0, day: "saturday"},
|
|
34
|
+
{close: 0, open: 0, day: "sunday"},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
export const cBusinessInfo: oBusinessInfo = {
|
|
38
|
+
version: "v2024",
|
|
39
|
+
name: "",
|
|
40
|
+
address: cAddress,
|
|
41
|
+
phones: [],
|
|
42
|
+
email: "",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const cBusinessDeadlines: oBusinessDeadlines = {
|
|
46
|
+
weeks: 0,
|
|
47
|
+
interest: 0
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const cBusinessConfig: oBusinessConfig = {
|
|
51
|
+
version: "",
|
|
52
|
+
apiVersion: "",
|
|
53
|
+
adminVersion: "",
|
|
54
|
+
mobileVersion: "",
|
|
55
|
+
mobileVersionPrev: "",
|
|
56
|
+
deadlines: [],
|
|
57
|
+
downloadsClient: false,
|
|
58
|
+
passportPaymentReference: false,
|
|
59
|
+
conektaPaymentReference: false,
|
|
60
|
+
conektaPaymentLink: false,
|
|
61
|
+
dynamicPaymentReference: false,
|
|
62
|
+
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"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export class FactoryBusiness {
|
|
68
|
+
|
|
69
|
+
public static FormBusinessInfo(info?: oBusinessInfo) {
|
|
70
|
+
let data = cBusinessInfo
|
|
71
|
+
|
|
72
|
+
if (info) data = info
|
|
73
|
+
|
|
74
|
+
if (!info?.address) data.address = cAddress
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
name: new UntypedFormControl(data.name, Validators.required),
|
|
78
|
+
email: new UntypedFormControl(data.email, [Validators.required, Validators.email]),
|
|
79
|
+
desc: new UntypedFormControl(data.desc, [Validators.required, Validators.email]),
|
|
80
|
+
street: new UntypedFormControl(data.address.street, Validators.required),
|
|
81
|
+
neighbor: new UntypedFormControl(data.address.neighbor, Validators.required),
|
|
82
|
+
cp: new UntypedFormControl(data.address.zip, Validators.required),
|
|
83
|
+
ext: new UntypedFormControl(data.address.ext, Validators.required),
|
|
84
|
+
int: new UntypedFormControl(data.address.int),
|
|
85
|
+
city: new UntypedFormControl(data.address.city, Validators.required),
|
|
86
|
+
state: new UntypedFormControl(data.address.state, Validators.required),
|
|
87
|
+
phones: new UntypedFormControl(data.phones),
|
|
88
|
+
mondayOpen: new UntypedFormControl(data.schedule?.monday.open),
|
|
89
|
+
mondayClose: new UntypedFormControl(data.schedule?.monday.close),
|
|
90
|
+
tuesdayOpen: new UntypedFormControl(data.schedule?.tuesday.open),
|
|
91
|
+
tuesdayClose: new UntypedFormControl(data.schedule?.tuesday.close),
|
|
92
|
+
wednesdayOpen: new UntypedFormControl(data.schedule?.wednesday.open),
|
|
93
|
+
wednesdayClose: new UntypedFormControl(data.schedule?.wednesday.close),
|
|
94
|
+
thursdayOpen: new UntypedFormControl(data.schedule?.thursday.open),
|
|
95
|
+
thursdayClose: new UntypedFormControl(data.schedule?.thursday.close),
|
|
96
|
+
fridayOpen: new UntypedFormControl(data.schedule?.friday.open),
|
|
97
|
+
fridayClose: new UntypedFormControl(data.schedule?.friday.close),
|
|
98
|
+
saturdayOpen: new UntypedFormControl(data.schedule?.saturday.open),
|
|
99
|
+
saturdayClose: new UntypedFormControl(data.schedule?.saturday.close),
|
|
100
|
+
sundayOpen: new UntypedFormControl(data.schedule?.sunday.open),
|
|
101
|
+
sundayClose: new UntypedFormControl(data.schedule?.sunday.close),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static CreateBusinessInfoObj(data: oTmpBusinessConfig) {
|
|
107
|
+
const address: oAddress = cAddress
|
|
108
|
+
|
|
109
|
+
const schedule: oWeekSchedule = {
|
|
110
|
+
monday: cDaySchedule,
|
|
111
|
+
tuesday: cDaySchedule,
|
|
112
|
+
wednesday: cDaySchedule,
|
|
113
|
+
thursday: cDaySchedule,
|
|
114
|
+
friday: cDaySchedule,
|
|
115
|
+
saturday: cDaySchedule,
|
|
116
|
+
sunday: cDaySchedule
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (data.street) address.street = data.street
|
|
120
|
+
if (data.state) address.state = data.state
|
|
121
|
+
if (data.neighbor) address.neighbor = data.neighbor
|
|
122
|
+
if (data.city) address.city = data.city
|
|
123
|
+
if (data.ext) address.ext = data.ext
|
|
124
|
+
if (data.int) address.int = data.int
|
|
125
|
+
if (data.cp) address.zip = data.cp
|
|
126
|
+
|
|
127
|
+
if (data.mondayOpen) schedule.monday.open = Number(data.mondayOpen)
|
|
128
|
+
if (data.mondayClose) schedule.monday.close = Number(data.mondayClose)
|
|
129
|
+
|
|
130
|
+
if (data.tuesdayOpen) schedule.tuesday.open = Number(data.tuesdayOpen)
|
|
131
|
+
if (data.tuesdayClose) schedule.tuesday.close = Number(data.tuesdayClose)
|
|
132
|
+
|
|
133
|
+
if (data.wednesdayOpen) schedule.wednesday.open = Number(data.wednesdayOpen)
|
|
134
|
+
if (data.wednesdayClose) schedule.wednesday.close = Number(data.wednesdayClose)
|
|
135
|
+
|
|
136
|
+
if (data.thursdayOpen) schedule.thursday.open = Number(data.thursdayOpen)
|
|
137
|
+
if (data.thursdayClose) schedule.thursday.close = Number(data.thursdayClose)
|
|
138
|
+
|
|
139
|
+
if (data.fridayOpen) schedule.friday.open = Number(data.fridayOpen)
|
|
140
|
+
if (data.fridayClose) schedule.friday.close = Number(data.fridayClose)
|
|
141
|
+
|
|
142
|
+
if (data.saturdayOpen) schedule.saturday.open = Number(data.saturdayOpen)
|
|
143
|
+
if (data.saturdayClose) schedule.saturday.close = Number(data.saturdayClose)
|
|
144
|
+
|
|
145
|
+
if (data.sundayOpen) schedule.sunday.open = Number(data.sundayOpen)
|
|
146
|
+
if (data.sundayClose) schedule.sunday.close = Number(data.sundayClose)
|
|
147
|
+
|
|
148
|
+
const info: oBusinessInfo = {
|
|
149
|
+
version: "v2024",
|
|
150
|
+
name: data.name ? data.name : "",
|
|
151
|
+
address: address,
|
|
152
|
+
phones: data.phones ? data.phones : [],
|
|
153
|
+
email: data.email ? data.email : "",
|
|
154
|
+
schedule: schedule,
|
|
155
|
+
desc: data.desc ? data.desc : ""
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return info
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public static FormDeadlineConfig(data: oBusinessDeadlines) {
|
|
162
|
+
// if (!data) data = cBusinessDeadlines
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
weeks: new UntypedFormControl(data.weeks),
|
|
166
|
+
interest: new UntypedFormControl(data.interest),
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public static FormBusinessConfig(config?: oBusinessConfig) {
|
|
171
|
+
let data = cBusinessConfig
|
|
172
|
+
if (config) data = config
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
downloadsClient: new UntypedFormControl(data.downloadsClient),
|
|
176
|
+
passportPaymentReference: new UntypedFormControl(data.passportPaymentReference),
|
|
177
|
+
conektaPaymentReference: new UntypedFormControl(data.conektaPaymentReference),
|
|
178
|
+
conektaPaymentLink: new UntypedFormControl(data.conektaPaymentLink),
|
|
179
|
+
dynamicPaymentReference: new UntypedFormControl(data.dynamicPaymentReference),
|
|
180
|
+
deadlines: new UntypedFormArray([])
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public static testBusiness(message: string) {
|
|
185
|
+
return `Message ${message}`
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import {oClient, oUserReference} from '../objects/oClient';
|
|
2
|
+
import {iConektaRecurrent, iConektaSources} from '../objects/oConekta';
|
|
3
|
+
import {oContract} from '../objects/oContract';
|
|
4
|
+
import {cContract} from './UtilContract';
|
|
5
|
+
import {IDCAccount, IDCClient} from './UtilDynamiCore';
|
|
6
|
+
import {oFinancial} from '../objects/oFinancial';
|
|
7
|
+
import { tyClientContract } from "../../v2/objects/oUtil";
|
|
8
|
+
import {cConektaRecurrent} from '../../v2/constant/constants';
|
|
9
|
+
import {eClientStatus} from '../../v2/enum/EnumClient';
|
|
10
|
+
|
|
11
|
+
export const cClient: oClient = {
|
|
12
|
+
id: "",
|
|
13
|
+
name: "",
|
|
14
|
+
username: "",
|
|
15
|
+
email: "",
|
|
16
|
+
phone: "",
|
|
17
|
+
curp: "",
|
|
18
|
+
contract_temporary: "",
|
|
19
|
+
conekta_id: "",
|
|
20
|
+
userReferences: [],
|
|
21
|
+
status: ""
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface oClientConekta {
|
|
25
|
+
ravcredit: oClient;
|
|
26
|
+
conekta: iConektaRecurrent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const cUserReference: oUserReference = {
|
|
30
|
+
name: "",
|
|
31
|
+
phone: "",
|
|
32
|
+
relationship: ""
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const cClientConekta: oClientConekta = {
|
|
36
|
+
conekta: cConektaRecurrent,
|
|
37
|
+
ravcredit: cClient
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface iClientContract {
|
|
41
|
+
client: oClient;
|
|
42
|
+
contract: oContract;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const cClientContract: iClientContract = {
|
|
46
|
+
client: cClient,
|
|
47
|
+
contract: cContract,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class FactoryClient {
|
|
51
|
+
|
|
52
|
+
public static CreateClientToConektaObj(data: oClient) {
|
|
53
|
+
const o: any = {}
|
|
54
|
+
if (data.name && data.name.length > 0) o.name = data.name;
|
|
55
|
+
if (data.username && data.name.length > 0) o.username = data.username;
|
|
56
|
+
if (data.email && data.email.length > 0) o.email = data.email;
|
|
57
|
+
if (data.phone && data.phone.length > 0) o.phone = String(data.phone);
|
|
58
|
+
if (data.curp && data.curp.length > 0) o.curp = data.curp;
|
|
59
|
+
if (data.userReferences && data.userReferences.length > 0) o.userReferences = data.userReferences;
|
|
60
|
+
if (data.contract) o.contract = data.contract;
|
|
61
|
+
if (data.createdAt) o.createdAt = data.createdAt;
|
|
62
|
+
if (data.lastLogin) o.lastLogin = data.lastLogin;
|
|
63
|
+
if (data.conekta_id) o.conekta_id = data.conekta_id;
|
|
64
|
+
|
|
65
|
+
return o
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static CreateClientFromFormObj(data: any, client?: oClient): oClient {
|
|
69
|
+
const o: oClient = {
|
|
70
|
+
id: "",
|
|
71
|
+
name: data["client"][0].name,
|
|
72
|
+
username: data["auth"][0].username,
|
|
73
|
+
password: data["auth"][0].password,
|
|
74
|
+
email: data["client"][0].email,
|
|
75
|
+
phone: String(data["client"][0].phone),
|
|
76
|
+
curp: data["client"][0].curp,
|
|
77
|
+
userReferences: data["client"][0].userReferences,
|
|
78
|
+
status: eClientStatus.ACTIVE
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (client != undefined) {
|
|
82
|
+
if (client.dynamic_id) o.dynamic_id = client.dynamic_id;
|
|
83
|
+
if (client.dynamic_account) o.dynamic_account = client.dynamic_account;
|
|
84
|
+
if (client.conekta_id) o.conekta_id = client.conekta_id;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return o
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public static CreateClientConektaObj(data: oClient, finalDate: number) {
|
|
91
|
+
const sources: iConektaSources = {
|
|
92
|
+
type: "oxxo_recurrent",
|
|
93
|
+
expires_at: finalDate
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
name: data.name,
|
|
97
|
+
email: data.email,
|
|
98
|
+
phone: data.phone,
|
|
99
|
+
contract: data.contract_temporary,
|
|
100
|
+
client_id: data.id,
|
|
101
|
+
payment_sources: [sources]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public static MapperConektaClient(
|
|
106
|
+
client: oClient,
|
|
107
|
+
conekta: iConektaRecurrent,
|
|
108
|
+
): iClientContract {
|
|
109
|
+
const o: oClient = client
|
|
110
|
+
|
|
111
|
+
o.name = conekta.name
|
|
112
|
+
o.email = conekta.email
|
|
113
|
+
o.phone = conekta.phone
|
|
114
|
+
o.conekta_id = conekta.id
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
client: o,
|
|
118
|
+
contract: cContract
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public static MapperTypeContCli_Client(_client: tyClientContract): oClient {
|
|
123
|
+
const client: oClient = {
|
|
124
|
+
id: _client.id,
|
|
125
|
+
name: _client.name,
|
|
126
|
+
username: _client.username,
|
|
127
|
+
email: _client.email,
|
|
128
|
+
phone: _client.phone,
|
|
129
|
+
curp: _client.curp,
|
|
130
|
+
userReferences: _client.userReferences,
|
|
131
|
+
status: _client.status,
|
|
132
|
+
contract: _client.contract,
|
|
133
|
+
reference: _client.reference,
|
|
134
|
+
references: _client.references,
|
|
135
|
+
conekta_id: _client.conekta_id,
|
|
136
|
+
dynamic_account: _client.dynamic_account,
|
|
137
|
+
token: _client.token,
|
|
138
|
+
contract_temporary: _client.contract_temporary,
|
|
139
|
+
lastLogin: _client.lastLogin,
|
|
140
|
+
dynamic_id: _client.dynamic_id,
|
|
141
|
+
createdAt: _client.createdAt,
|
|
142
|
+
payments: _client.payments,
|
|
143
|
+
password: _client.password,
|
|
144
|
+
contractUrl: _client.contractUrl,
|
|
145
|
+
dynamic_ref: _client.dynamic_ref,
|
|
146
|
+
exists: _client.exists,
|
|
147
|
+
passport_id: _client.passport_id,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return client
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public static MapperDynamicClient(
|
|
154
|
+
dynamic: IDCClient,
|
|
155
|
+
client: oClient,
|
|
156
|
+
contract: oContract,
|
|
157
|
+
clientDyn?: IDCClient,
|
|
158
|
+
account?: IDCAccount,
|
|
159
|
+
): iClientContract {
|
|
160
|
+
// constant o: tyClientContract = cTyClientContract
|
|
161
|
+
|
|
162
|
+
/* Client ------------------------------------------------------ */
|
|
163
|
+
client.username = `${dynamic.pii.name} ${dynamic.pii.motherlastname} ${dynamic.pii.lastname}`
|
|
164
|
+
client.phone = dynamic.pii.phone as string
|
|
165
|
+
client.dynamic_id = dynamic.id
|
|
166
|
+
client.curp = dynamic.pii.curp
|
|
167
|
+
client.email = dynamic.pii.email
|
|
168
|
+
|
|
169
|
+
if (account)
|
|
170
|
+
client.dynamic_account = account.id
|
|
171
|
+
|
|
172
|
+
/* Auth ---------------------------------------------------------- */
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
/* Device -------------------------------------------------------- */
|
|
176
|
+
contract.device.IMEI = clientDyn!.pii.imei
|
|
177
|
+
contract.device.device = clientDyn!.pii.model
|
|
178
|
+
|
|
179
|
+
/* Contract ------------------------------------------------------ */
|
|
180
|
+
contract.by = clientDyn!.pii.seller_name
|
|
181
|
+
|
|
182
|
+
if (clientDyn!.pii.fotografia_del_cliente_con_el_equipo != undefined) {
|
|
183
|
+
const oPhoto = clientDyn!.pii.fotografia_del_cliente_con_el_equipo!
|
|
184
|
+
if (oPhoto != "") {
|
|
185
|
+
const _photo = JSON.parse(oPhoto)
|
|
186
|
+
if (_photo)
|
|
187
|
+
contract.photo = _photo[0].url
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
contract.address.state = dynamic.pii.state
|
|
192
|
+
contract.address.city = dynamic.pii.city
|
|
193
|
+
contract.address.street = dynamic.pii.street
|
|
194
|
+
contract.address.ext = dynamic.pii.num_ext as string
|
|
195
|
+
contract.address.zip = dynamic.pii.zipcode as string
|
|
196
|
+
contract.address.neighbor = dynamic.pii.colony
|
|
197
|
+
|
|
198
|
+
/* Financial ------------------------------------------------------ */
|
|
199
|
+
contract.dynamicAccount = Number(account?.id)
|
|
200
|
+
|
|
201
|
+
if (account?.config.installments) {
|
|
202
|
+
contract.financial.deadlines = {
|
|
203
|
+
weeks: account.config.installments,
|
|
204
|
+
interest: 0
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (account?.properties.expected_disbursed)
|
|
209
|
+
contract.financial.total = account?.properties.expected_disbursed
|
|
210
|
+
|
|
211
|
+
if (account?.properties.principal_disbursed)
|
|
212
|
+
contract.financial.financed = account?.properties.principal_disbursed
|
|
213
|
+
|
|
214
|
+
if (account?.properties.amount_commission_opening) {
|
|
215
|
+
contract.financial.initial = account?.properties.amount_commission_opening
|
|
216
|
+
contract.financial.amount_commission_opening = account?.properties.amount_commission_opening
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
contract.financial.interest_rate = Number(clientDyn!.pii.interest_rate)
|
|
220
|
+
contract.financial.interest_arrears = account?.config.interest_arrears
|
|
221
|
+
contract.financial.commission_opening = account?.config.commission_opening
|
|
222
|
+
contract.financial.credit_type = account?.config.credit_type
|
|
223
|
+
|
|
224
|
+
contract.financial.principal_disbursed = account?.properties.principal_disbursed
|
|
225
|
+
contract.financial.expected_disbursed = account?.properties.expected_disbursed
|
|
226
|
+
|
|
227
|
+
contract.financial.weeklyPayment = Number(clientDyn!.pii.amount_by_period)
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
client: client,
|
|
231
|
+
contract: contract,
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
public static MapperFinancialContract(
|
|
236
|
+
contract: oContract,
|
|
237
|
+
account: IDCAccount,
|
|
238
|
+
): oFinancial {
|
|
239
|
+
|
|
240
|
+
contract.dynamicAccount = Number(account.id)
|
|
241
|
+
|
|
242
|
+
if (account.config.installments) {
|
|
243
|
+
contract.financial.deadlines = {
|
|
244
|
+
weeks: account.config.installments,
|
|
245
|
+
interest: 0
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const total =
|
|
250
|
+
account.config.financed_amount != undefined ? account.config.financed_amount : 0
|
|
251
|
+
|
|
252
|
+
if (total > 0)
|
|
253
|
+
contract.financial.total = total
|
|
254
|
+
|
|
255
|
+
// if (account.properties.expected_disbursed)
|
|
256
|
+
const expected_disbursed =
|
|
257
|
+
account.properties.expected_disbursed != undefined ? account.properties.expected_disbursed : 0
|
|
258
|
+
|
|
259
|
+
if (expected_disbursed > 0) contract.financial.total = expected_disbursed
|
|
260
|
+
contract.financial.expected_disbursed = expected_disbursed
|
|
261
|
+
|
|
262
|
+
contract.financial.interest_rate = account.config.interest_rate
|
|
263
|
+
contract.financial.interest_arrears = account.config.interest_arrears
|
|
264
|
+
|
|
265
|
+
// if (account.properties.principal_disbursed)
|
|
266
|
+
if (account.properties.principal_disbursed > 0)
|
|
267
|
+
contract.financial.financed = account.properties.principal_disbursed
|
|
268
|
+
|
|
269
|
+
contract.financial.principal_disbursed = account.properties.principal_disbursed
|
|
270
|
+
|
|
271
|
+
const amount_commission_opening =
|
|
272
|
+
account.properties.amount_commission_opening != undefined ? account.properties.amount_commission_opening : 0
|
|
273
|
+
|
|
274
|
+
if (amount_commission_opening > 0)
|
|
275
|
+
contract.financial.initial = amount_commission_opening
|
|
276
|
+
|
|
277
|
+
contract.financial.amount_commission_opening = amount_commission_opening
|
|
278
|
+
|
|
279
|
+
contract.financial.interest_arrears = account.config.interest_arrears
|
|
280
|
+
contract.financial.commission_opening = account.config.commission_opening
|
|
281
|
+
contract.financial.credit_type = account.config.credit_type
|
|
282
|
+
|
|
283
|
+
contract.financial.clabe = String(account.properties.clabe!)
|
|
284
|
+
|
|
285
|
+
return contract.financial
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public static CheckEmail =
|
|
289
|
+
(email: string): boolean => email.includes("@") && email.endsWith(".com")
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export enum eIdentityTypes {
|
|
293
|
+
SELFIE = 'SELFIE',
|
|
294
|
+
IDENTITY_FRONT = 'IDENTITY_FRONT',
|
|
295
|
+
IDENTITY_BACK = 'IDENTITY_BACK',
|
|
296
|
+
PASSPORT_FRONT = 'PASSPORT_FRONT',
|
|
297
|
+
PASSPORT_BACK = 'PASSPORT_BACK',
|
|
298
|
+
SERVICE='SERVICE',
|
|
299
|
+
WITH_DEVICE='WITH_DEVICE',
|
|
300
|
+
}
|