@movalib/movalib-commons 1.60.0 → 1.62.0
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/dist/src/MovaLogin.d.ts +2 -2
- package/dist/src/MovaLogin.js +22 -18
- package/dist/src/helpers/Tools.d.ts +4 -3
- package/dist/src/helpers/Tools.js +120 -50
- package/dist/src/helpers/Validator.js +3 -2
- package/package.json +1 -1
- package/src/components/QrCodePLVContainer/QrCodePLVContainer.tsx +135 -103
- package/src/helpers/Enums.ts +8 -0
- package/src/helpers/Tools.ts +214 -124
- package/src/helpers/Validator.ts +28 -26
- package/src/models/Document.ts +17 -2
- package/src/models/Event.ts +65 -3
package/src/models/Event.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DocumentState,
|
|
3
|
+
DocumentType,
|
|
4
|
+
EventState,
|
|
5
|
+
EventType,
|
|
6
|
+
OrderPreference,
|
|
7
|
+
QuoteState,
|
|
8
|
+
} from "../helpers/Enums";
|
|
2
9
|
import Address from "./Address";
|
|
3
10
|
import Customer from "./Customer";
|
|
4
11
|
import Document from "./Document";
|
|
@@ -82,7 +89,10 @@ export default class Event {
|
|
|
82
89
|
origin?: string;
|
|
83
90
|
quoteLastSendingTime?: Date;
|
|
84
91
|
invoiceSendingDate?: Date;
|
|
85
|
-
|
|
92
|
+
creationDate?: Date;
|
|
93
|
+
updatedDate?: Date;
|
|
94
|
+
quoteFirstSendingTime?: Date;
|
|
95
|
+
lastQuoteCreationDate?: Date;
|
|
86
96
|
constructor(
|
|
87
97
|
id: string,
|
|
88
98
|
ownerId: number,
|
|
@@ -111,7 +121,11 @@ export default class Event {
|
|
|
111
121
|
interventionEndTime?: Date,
|
|
112
122
|
quoteLastSendingTime?: Date,
|
|
113
123
|
invoiceSendingDate?: Date,
|
|
114
|
-
orders?: order[]
|
|
124
|
+
orders?: order[],
|
|
125
|
+
creationDate?: Date,
|
|
126
|
+
updatedDate?: Date,
|
|
127
|
+
lastQuoteCreationDate?: Date,
|
|
128
|
+
quoteFirstSendingTime?: Date
|
|
115
129
|
) {
|
|
116
130
|
this.id = id;
|
|
117
131
|
this.notes = notes;
|
|
@@ -149,6 +163,14 @@ export default class Event {
|
|
|
149
163
|
? new Date(invoiceSendingDate)
|
|
150
164
|
: undefined;
|
|
151
165
|
this.orders = orders;
|
|
166
|
+
this.creationDate = creationDate ? new Date(creationDate) : undefined;
|
|
167
|
+
this.updatedDate = updatedDate ? new Date(updatedDate) : undefined;
|
|
168
|
+
this.lastQuoteCreationDate = lastQuoteCreationDate
|
|
169
|
+
? new Date(lastQuoteCreationDate)
|
|
170
|
+
: undefined;
|
|
171
|
+
this.quoteFirstSendingTime = quoteFirstSendingTime
|
|
172
|
+
? new Date(quoteFirstSendingTime)
|
|
173
|
+
: undefined;
|
|
152
174
|
}
|
|
153
175
|
|
|
154
176
|
static getPrestationsList(event: Event): string[] {
|
|
@@ -158,4 +180,44 @@ export default class Event {
|
|
|
158
180
|
|
|
159
181
|
return [];
|
|
160
182
|
}
|
|
183
|
+
static getCurrentQuote(event: Event): Document | null {
|
|
184
|
+
if (event.documents) {
|
|
185
|
+
const quoteDocument = event.documents.filter(
|
|
186
|
+
(doc) => doc.type === DocumentType.USER_APPOINTMENT_QUOTE
|
|
187
|
+
);
|
|
188
|
+
if (event.type === EventType.QUOTE) {
|
|
189
|
+
const state = event.state as unknown as QuoteState;
|
|
190
|
+
if (
|
|
191
|
+
state === QuoteState.QUOTE_DRAFT ||
|
|
192
|
+
state === QuoteState.QUOTE_SENT
|
|
193
|
+
) {
|
|
194
|
+
return (
|
|
195
|
+
quoteDocument.find((doc) => doc.state === DocumentState.PENDING) ??
|
|
196
|
+
null
|
|
197
|
+
);
|
|
198
|
+
} else if (state === QuoteState.QUOTE_REJECTED) {
|
|
199
|
+
return (
|
|
200
|
+
quoteDocument
|
|
201
|
+
.filter((doc) => doc.state === DocumentState.REJECTED)
|
|
202
|
+
.sort(
|
|
203
|
+
(a, b) =>
|
|
204
|
+
new Date(b.creationDate!).getTime() -
|
|
205
|
+
new Date(a.creationDate!).getTime()
|
|
206
|
+
)[0] ?? null
|
|
207
|
+
);
|
|
208
|
+
} else if (state === QuoteState.QUOTE_ACCEPTED) {
|
|
209
|
+
return (
|
|
210
|
+
quoteDocument.find((doc) => doc.state === DocumentState.APPROVED) ??
|
|
211
|
+
null
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
return (
|
|
216
|
+
quoteDocument.find((doc) => doc.state === DocumentState.APPROVED) ??
|
|
217
|
+
null
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
161
223
|
}
|