@unimaze/billing 0.21.71 → 1.0.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/lib/common/components/customer/index.js +1 -1
- package/lib/common/components/input/index.d.ts +2 -0
- package/lib/common/components/input/index.js +6 -3
- package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +6 -0
- package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +19 -1
- package/lib/common/components/invoice-preview/index.d.ts +23 -0
- package/lib/common/components/invoice-preview/index.js +17 -1
- package/lib/common/components/session-bar/index.d.ts +34 -0
- package/lib/common/components/session-bar/index.js +79 -0
- package/lib/common/components/supplier/CityAutofill.d.ts +2 -0
- package/lib/common/components/supplier/CityAutofill.js +4 -3
- package/lib/common/components/supplier/SendOnBehalfOf.d.ts +88 -0
- package/lib/common/components/supplier/SendOnBehalfOf.js +281 -0
- package/lib/common/components/supplier/index.d.ts +16 -0
- package/lib/common/components/supplier/index.js +66 -16
- package/lib/common/types/CommonProps.d.ts +14 -0
- package/lib/common/types/SellerSelection.d.ts +16 -0
- package/lib/common/types/SellerSelection.js +10 -0
- package/lib/create-invoice/IntlLoader.js +1 -1
- package/lib/create-invoice/index.d.ts +8 -0
- package/lib/create-invoice/index.js +121 -41
- package/lib/style/index.css +51 -0
- package/lib/translations/locales/en.json +23 -0
- package/lib/translations/locales/is.json +23 -0
- package/lib/translations/locales.d.ts +46 -0
- package/lib/utils/ApiUtility.d.ts +9 -2
- package/lib/utils/ApiUtility.js +30 -3
- package/lib/utils/ConversionUtility.d.ts +6 -2
- package/lib/utils/ConversionUtility.js +16 -14
- package/lib/utils/WizardSnapshotUtility.d.ts +20 -0
- package/lib/utils/WizardSnapshotUtility.js +88 -0
- package/package.json +2 -2
- package/lib/common/components/attachments/ListAttachments.d.ts +0 -10
- package/lib/common/components/attachments/ListAttachments.js +0 -143
|
@@ -69,6 +69,9 @@ var BillingLineUtility_1 = require("../utils/BillingLineUtility");
|
|
|
69
69
|
var paymentMethodForConversion_1 = require("../common/components/payment-method/paymentMethodForConversion");
|
|
70
70
|
var uuid_1 = require("uuid");
|
|
71
71
|
var ApiUtility_1 = require("../utils/ApiUtility");
|
|
72
|
+
var WizardSnapshotUtility_1 = require("../utils/WizardSnapshotUtility");
|
|
73
|
+
var SellerSelection_1 = require("../common/types/SellerSelection");
|
|
74
|
+
var session_bar_1 = __importDefault(require("../common/components/session-bar"));
|
|
72
75
|
var ConversionUtility_1 = require("../utils/ConversionUtility");
|
|
73
76
|
var icons_1 = require("@ant-design/icons");
|
|
74
77
|
var reaptcha_1 = __importDefault(require("reaptcha"));
|
|
@@ -153,6 +156,14 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
153
156
|
id: "createInvoice_invoiceHadValidationErrors",
|
|
154
157
|
defaultMessage: "Created invoice had validation errors",
|
|
155
158
|
},
|
|
159
|
+
createInvoice_sessionExpired: {
|
|
160
|
+
id: "createInvoice_sessionExpired",
|
|
161
|
+
defaultMessage: "Your login has expired. Log in again to continue.",
|
|
162
|
+
},
|
|
163
|
+
createInvoice_attachmentsNotRestored: {
|
|
164
|
+
id: "createInvoice_attachmentsNotRestored",
|
|
165
|
+
defaultMessage: "You logged in again: please add the attachments again.",
|
|
166
|
+
},
|
|
156
167
|
});
|
|
157
168
|
/**
|
|
158
169
|
* Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
|
|
@@ -160,12 +171,16 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
160
171
|
* @component
|
|
161
172
|
*/
|
|
162
173
|
var CreateInvoiceConstructor = function (props) {
|
|
163
|
-
var _a, _b, _c, _d, _e;
|
|
174
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
164
175
|
var recaptchaRef = react_1.default.useRef(null);
|
|
165
176
|
var intl = props.intl;
|
|
166
177
|
var form = antd_1.Form.useForm()[0];
|
|
178
|
+
var isLoginRequired = !!props.accessToken;
|
|
179
|
+
// the wizard saved before a re-login; read without removing it (StrictMode runs initialisers twice), cleared once restored
|
|
180
|
+
var restoredSnapshot = (0, react_1.useState)(function () { return (isLoginRequired ? (0, WizardSnapshotUtility_1.readWizardSnapshot)() : undefined); })[0];
|
|
181
|
+
var isReLoggingIn = react_1.default.useRef(false);
|
|
167
182
|
var width = (0, react_use_1.useWindowSize)().width;
|
|
168
|
-
var
|
|
183
|
+
var _j = (0, react_1.useState)(false), isMobile = _j[0], setIsMobile = _j[1];
|
|
169
184
|
(0, react_1.useEffect)(function () {
|
|
170
185
|
if (width < 768) {
|
|
171
186
|
setIsMobile(true);
|
|
@@ -174,31 +189,57 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
174
189
|
setIsMobile(false);
|
|
175
190
|
}
|
|
176
191
|
}, [width]);
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
var
|
|
181
|
-
var
|
|
182
|
-
var
|
|
183
|
-
var
|
|
184
|
-
var
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
var
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
var
|
|
192
|
-
var
|
|
193
|
-
var
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
var
|
|
197
|
-
var
|
|
198
|
-
var
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var
|
|
192
|
+
var _k = (0, react_1.useState)(true), isSubmitDisabled = _k[0], setIsSubmitDisabled = _k[1];
|
|
193
|
+
var _l = (0, react_1.useState)(false), isBackButtonVisible = _l[0], setIsBackButtonVisible = _l[1];
|
|
194
|
+
var _m = (0, react_1.useState)(true), isNextStepDisabled = _m[0], setIsNextStepDisabled = _m[1];
|
|
195
|
+
var _o = (0, react_1.useState)(false), isNextStepVisible = _o[0], setIsNextStepVisible = _o[1];
|
|
196
|
+
var _p = (0, react_1.useState)((_a = restoredSnapshot === null || restoredSnapshot === void 0 ? void 0 : restoredSnapshot.activeStep) !== null && _a !== void 0 ? _a : 0), activeStep = _p[0], setActiveStep = _p[1];
|
|
197
|
+
var _q = (0, react_1.useState)(true), isWelcomeModalOpen = _q[0], setIsWelcomeModalOpen = _q[1];
|
|
198
|
+
var _r = (0, react_1.useState)(""), supplierEmail = _r[0], setSupplierEmail = _r[1];
|
|
199
|
+
var _s = (0, react_1.useState)(false), isSaveFieldValuesSelected = _s[0], setIsSaveFieldValuesSelected = _s[1];
|
|
200
|
+
var _t = (0, react_1.useState)((_b = restoredSnapshot === null || restoredSnapshot === void 0 ? void 0 : restoredSnapshot.chosenCustomer) !== null && _b !== void 0 ? _b : (0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0])), chosenCustomer = _t[0], setChosenCustomer = _t[1];
|
|
201
|
+
var _u = (0, react_1.useState)(false), sendCopy = _u[0], setSendCopy = _u[1];
|
|
202
|
+
var _v = react_1.default.useState(""), referenceIdentifierValidateStatus = _v[0], setReferenceIdentifierValidateStatus = _v[1];
|
|
203
|
+
var _w = (0, react_1.useState)(true), referenceIdentifierIsMandatory = _w[0], setReferenceIdentifierIsMandatory = _w[1];
|
|
204
|
+
var _x = (0, react_1.useState)(false), outsideVatScope = _x[0], setOutsideVatScope = _x[1];
|
|
205
|
+
var _y = (0, react_1.useState)(false), captchaVerified = _y[0], setCaptchaVerified = _y[1];
|
|
206
|
+
var _z = (0, react_1.useState)((_c = restoredSnapshot === null || restoredSnapshot === void 0 ? void 0 : restoredSnapshot.removedInvoiceLine) !== null && _c !== void 0 ? _c : {}), removedInvoiceLine = _z[0], setRemovedInvoiceLine = _z[1];
|
|
207
|
+
var _0 = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _0[0], setMissingRequiredDataTooltip = _0[1];
|
|
208
|
+
var _1 = (0, react_1.useState)(false), newLineSaved = _1[0], setNewLineSaved = _1[1];
|
|
209
|
+
var _2 = (0, react_1.useState)(0), numberOfAttemptedCalls = _2[0], setNumberOfAttemptedCalls = _2[1];
|
|
210
|
+
var _3 = (0, react_1.useState)(''), messageIdForRetryAttachments = _3[0], setMessageIdForRetryAttachments = _3[1];
|
|
211
|
+
var _4 = (0, react_1.useState)(''), tokenForRetryAttachments = _4[0], setTokenForRetryAttachments = _4[1];
|
|
212
|
+
var _5 = (0, react_1.useState)([]), allAttachments = _5[0], setAllAttachments = _5[1];
|
|
213
|
+
var _6 = (0, react_1.useState)(false), alreadyRetried = _6[0], setAlreadyRetried = _6[1];
|
|
214
|
+
var _7 = (0, react_1.useState)(AttachmentUploadStatus_1.SubmittingStatus.Pending), invoiceSubmittingStatus = _7[0], setInvoiceSubmittingStatus = _7[1];
|
|
215
|
+
var _8 = (0, react_1.useState)([]), allAttachmentsWithStatuses = _8[0], setAllAttachmentsWithStatuses = _8[1];
|
|
216
|
+
var _9 = (0, react_1.useState)(true), showWelcomeModal = _9[0], setShowWelcomeModal = _9[1];
|
|
217
|
+
// with login, the seller must be the person or a company they represent before continuing from the supplier step
|
|
218
|
+
var _10 = (0, react_1.useState)(null), seller = _10[0], setSeller = _10[1];
|
|
219
|
+
var isSellerVerified = !!seller;
|
|
220
|
+
var _11 = (0, react_1.useState)([]), representedCompanies = _11[0], setRepresentedCompanies = _11[1];
|
|
221
|
+
var holdsProcuration = representedCompanies.some(function (c) { var _a; return (0, SellerSelection_1.mayRepresent)(c.callerRoles) && ((_a = c.callerRoles) !== null && _a !== void 0 ? _a : []).includes(SellerSelection_1.PROCURATION); });
|
|
222
|
+
/** True when the IdentityServer token expires within a minute: the next RAPI call would be refused */
|
|
223
|
+
var isSessionExpiring = function () { return isLoginRequired && !!props.accessTokenExpiresAt && props.accessTokenExpiresAt - Date.now() < 60000; };
|
|
224
|
+
/** Saves the wizard and asks the host to log in again; the wizard is restored when it mounts after the login */
|
|
225
|
+
var startReLogin = function () {
|
|
226
|
+
if (isReLoggingIn.current)
|
|
227
|
+
return;
|
|
228
|
+
isReLoggingIn.current = true;
|
|
229
|
+
(0, WizardSnapshotUtility_1.saveWizardSnapshot)((0, WizardSnapshotUtility_1.createWizardSnapshot)(form.getFieldsValue(true), {
|
|
230
|
+
activeStep: activeStep,
|
|
231
|
+
chosenCustomer: chosenCustomer,
|
|
232
|
+
removedInvoiceLine: removedInvoiceLine,
|
|
233
|
+
seller: seller ? { isSelf: seller.isSelf, isoIdentifier: seller.isoIdentifier } : undefined,
|
|
234
|
+
}));
|
|
235
|
+
if (props.onLoginRequired) {
|
|
236
|
+
props.onLoginRequired();
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
isReLoggingIn.current = false;
|
|
240
|
+
antd_1.message.error(intl.formatMessage(exports.translationMessages.createInvoice_sessionExpired));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
202
243
|
var url = new URL(window.location.href);
|
|
203
244
|
var skipWelcomeModal = url.searchParams.has("skipintro");
|
|
204
245
|
if (skipWelcomeModal) {
|
|
@@ -209,7 +250,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
209
250
|
var getDefaultPaymentType = function (defaultPaymentType) {
|
|
210
251
|
return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
|
|
211
252
|
};
|
|
212
|
-
var
|
|
253
|
+
var _12 = (0, react_1.useState)({
|
|
213
254
|
invoice: {
|
|
214
255
|
supplier: {
|
|
215
256
|
address: {
|
|
@@ -235,7 +276,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
235
276
|
},
|
|
236
277
|
issueDate: (0, dayjs_1.default)(),
|
|
237
278
|
},
|
|
238
|
-
}), formData =
|
|
279
|
+
}), formData = _12[0], setFormData = _12[1];
|
|
239
280
|
(0, react_1.useEffect)(function () {
|
|
240
281
|
var _a, _b, _c;
|
|
241
282
|
var savedValuesObject = (0, LocalStorageUtility_1.getFormFromLocalStorage)(props.localStorageFormDataVersion);
|
|
@@ -246,12 +287,22 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
246
287
|
}
|
|
247
288
|
var invoice = savedValuesObject.invoice, rest = __rest(savedValuesObject, ["invoice"]);
|
|
248
289
|
var issueDate = invoice.issueDate, restOfInvoice = __rest(invoice, ["issueDate"]);
|
|
290
|
+
if (isLoginRequired && restOfInvoice.supplier) {
|
|
291
|
+
// with login the seller comes from the "On behalf of" banner; only the typed contact details are restored
|
|
292
|
+
restOfInvoice.supplier = { contact: restOfInvoice.supplier.contact };
|
|
293
|
+
}
|
|
249
294
|
form.setFieldsValue(__assign({ invoice: restOfInvoice }, rest));
|
|
250
295
|
}
|
|
296
|
+
if (restoredSnapshot) {
|
|
297
|
+
form.setFieldsValue(restoredSnapshot.values);
|
|
298
|
+
(0, WizardSnapshotUtility_1.clearWizardSnapshot)();
|
|
299
|
+
if (restoredSnapshot.hadAttachments)
|
|
300
|
+
antd_1.message.warning(intl.formatMessage(exports.translationMessages.createInvoice_attachmentsNotRestored));
|
|
301
|
+
}
|
|
251
302
|
}, []);
|
|
252
303
|
(0, react_1.useEffect)(function () {
|
|
253
304
|
validateFields();
|
|
254
|
-
}, [form, activeStep, newLineSaved, referenceIdentifierValidateStatus]);
|
|
305
|
+
}, [form, activeStep, newLineSaved, referenceIdentifierValidateStatus, isSellerVerified]);
|
|
255
306
|
(0, react_1.useEffect)(function () {
|
|
256
307
|
setSupplierEmail(form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]));
|
|
257
308
|
}, [form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])]);
|
|
@@ -323,7 +374,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
323
374
|
case 1: {
|
|
324
375
|
form.validateFields(__spreadArray(__spreadArray([], formPaths_1.supplierFieldPaths, true), [!outsideVatScope ? formPaths_1.vatNoFieldPath : []], false), { validateOnly: true })
|
|
325
376
|
.then(function () {
|
|
326
|
-
setIsNextStepDisabled(
|
|
377
|
+
setIsNextStepDisabled(isLoginRequired && !isSellerVerified);
|
|
327
378
|
setMissingRequiredDataTooltip(undefined);
|
|
328
379
|
})
|
|
329
380
|
.catch(function (error) {
|
|
@@ -407,6 +458,19 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
407
458
|
}
|
|
408
459
|
setActiveStep(activeStep - 1);
|
|
409
460
|
};
|
|
461
|
+
/** "Change" in the session bar: back to the supplier step, keeping the other steps */
|
|
462
|
+
var goToSupplierStep = function () {
|
|
463
|
+
if (activeStep >= 3 && removedInvoiceLine) {
|
|
464
|
+
// the last (empty) invoice line was removed when leaving the invoice step; put it back as handlePrevStep does
|
|
465
|
+
var currentInvoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
|
|
466
|
+
form.setFieldsValue({
|
|
467
|
+
invoice: {
|
|
468
|
+
invoiceLines: __spreadArray(__spreadArray([], currentInvoiceLines, true), [removedInvoiceLine], false),
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
setActiveStep(1);
|
|
473
|
+
};
|
|
410
474
|
var handleNextStep = function () {
|
|
411
475
|
if (activeStep === 2) {
|
|
412
476
|
var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
|
|
@@ -473,7 +537,14 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
473
537
|
processingMode: mapi_1.TransactionProcessingMode.Device,
|
|
474
538
|
services: services,
|
|
475
539
|
};
|
|
476
|
-
|
|
540
|
+
if (isSessionExpiring()) {
|
|
541
|
+
startReLogin();
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
var sellerIsoIdentifier = isLoginRequired
|
|
545
|
+
? (0, ConversionUtility_1.getIdentifierWithPrefix)(form.getFieldValue(["invoice", "supplier", "identifier"]))
|
|
546
|
+
: undefined;
|
|
547
|
+
(0, ApiUtility_1.getAuthToken)(props.rapiBaseUrl, chosenCustomer === null || chosenCustomer === void 0 ? void 0 : chosenCustomer.identifier, props.accessToken, sellerIsoIdentifier).then(function (getAuthTokenResponse) {
|
|
477
548
|
var token = getAuthTokenResponse.data;
|
|
478
549
|
if (!messageId) {
|
|
479
550
|
setActiveStep(activeStep + 1);
|
|
@@ -554,6 +625,14 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
554
625
|
antd_1.message.error(error.message);
|
|
555
626
|
}
|
|
556
627
|
});
|
|
628
|
+
}).catch(function (error) {
|
|
629
|
+
var _a, _b, _c;
|
|
630
|
+
// portals/auth refused: an expired login is renewed, anything else (e.g. no longer allowed for the seller) is shown
|
|
631
|
+
if (isLoginRequired && (0, ApiUtility_1.isUnauthorized)(error)) {
|
|
632
|
+
startReLogin();
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
antd_1.message.error((_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : error === null || error === void 0 ? void 0 : error.message);
|
|
557
636
|
});
|
|
558
637
|
if (recaptchaRef) {
|
|
559
638
|
if (recaptchaRef.current) {
|
|
@@ -589,16 +668,16 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
589
668
|
telephone: defaultCustomer.phoneNumber,
|
|
590
669
|
},
|
|
591
670
|
address: {
|
|
592
|
-
countryCode: (
|
|
593
|
-
city: (
|
|
594
|
-
postalZone: (
|
|
595
|
-
streetNameAndNumber: (
|
|
671
|
+
countryCode: (_d = defaultCustomer === null || defaultCustomer === void 0 ? void 0 : defaultCustomer.address) === null || _d === void 0 ? void 0 : _d.country,
|
|
672
|
+
city: (_e = defaultCustomer === null || defaultCustomer === void 0 ? void 0 : defaultCustomer.address) === null || _e === void 0 ? void 0 : _e.city,
|
|
673
|
+
postalZone: (_f = defaultCustomer === null || defaultCustomer === void 0 ? void 0 : defaultCustomer.address) === null || _f === void 0 ? void 0 : _f.postalCode,
|
|
674
|
+
streetNameAndNumber: (_g = defaultCustomer === null || defaultCustomer === void 0 ? void 0 : defaultCustomer.address) === null || _g === void 0 ? void 0 : _g.street,
|
|
596
675
|
},
|
|
597
676
|
identifier: defaultCustomer === null || defaultCustomer === void 0 ? void 0 : defaultCustomer.isoIdentifier,
|
|
598
677
|
name: defaultCustomer.name,
|
|
599
678
|
});
|
|
600
679
|
}
|
|
601
|
-
var
|
|
680
|
+
var _13 = (0, react_1.useState)(undefined), billingLinesMetadata = _13[0], setBillingLinesMetadata = _13[1];
|
|
602
681
|
var getBillingLines = function (changedValues, allValues) {
|
|
603
682
|
var invoiceLines = allValues.invoice.invoiceLines;
|
|
604
683
|
if (invoiceLines) {
|
|
@@ -643,6 +722,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
643
722
|
];
|
|
644
723
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
645
724
|
react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "middle", style: { alignItems: "center", marginBottom: "50px" } },
|
|
725
|
+
isLoginRequired && props.loggedInPerson && (react_1.default.createElement(session_bar_1.default, { person: props.loggedInPerson, seller: seller, canChangeSeller: !!seller && activeStep !== 1 && activeStep <= items.length, onChangeSeller: goToSupplierStep, delegationsUrl: holdsProcuration ? props.delegationsUrl : undefined, isMobile: isMobile })),
|
|
646
726
|
activeStep === items.length ? (react_1.default.createElement(components_1.InvoicePreviewHeader, { form: form, colorPrimary: props.colorPrimary })) : (activeStep < items.length && (react_1.default.createElement(antd_1.Steps, { style: { maxWidth: "900px", margin: isMobile ? 0 : "30px 0" }, current: activeStep, initial: 0, labelPlacement: "vertical", items: items, type: isMobile ? "navigation" : "default", size: isMobile ? "small" : "default", direction: "horizontal", responsive: false }))),
|
|
647
727
|
react_1.default.createElement(antd_1.Layout.Content, null,
|
|
648
728
|
react_1.default.createElement(antd_1.Flex, { style: { width: "100vw", padding: isMobile ? "0 20px" : 0 } },
|
|
@@ -674,7 +754,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
674
754
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 1 ? { display: "none" } : {} },
|
|
675
755
|
react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements, rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form, outsideVatScope: outsideVatScope, setOutsideVatScope: setOutsideVatScope, isMobile: isMobile, onSaveFieldValues: saveFieldValuesToLocalStorage, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
676
756
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
677
|
-
} }),
|
|
757
|
+
}, accessToken: props.accessToken, loggedInPerson: props.loggedInPerson, onSellerChange: setSeller, initialSeller: restoredSnapshot === null || restoredSnapshot === void 0 ? void 0 : restoredSnapshot.seller, onRepresentedCompaniesChange: setRepresentedCompanies, isSessionExpiring: isSessionExpiring, onSessionExpired: startReLogin }),
|
|
678
758
|
" "),
|
|
679
759
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 2 ? { display: "none" } : {} },
|
|
680
760
|
react_1.default.createElement(components_1.Invoice, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: referenceIdentifierValidateStatus, chosenCustomer: chosenCustomer, setReferenceIdentifierValidateStatus: setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset, billingLinesMetadata: billingLinesMetadata, outsideVatScope: outsideVatScope, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
@@ -684,7 +764,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
684
764
|
react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
685
765
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
686
766
|
}, localStorageFormDataVersion: props.localStorageFormDataVersion })),
|
|
687
|
-
activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer })),
|
|
767
|
+
activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer, sentBy: props.loggedInPerson && seller ? { person: props.loggedInPerson, seller: seller } : undefined })),
|
|
688
768
|
activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, { numberOfAttemptedCalls: numberOfAttemptedCalls, retryUploadingFailedAttachments: retryUploadingFailedAttachments, retrySubmittingInvoice: retrySubmittingInvoice, alreadyRetried: alreadyRetried, invoiceSubmittingStatus: invoiceSubmittingStatus, allAttachments: allAttachments, allAttachmentsWithStatuses: allAttachmentsWithStatuses }),
|
|
689
769
|
activeStep === items.length && (react_1.default.createElement(antd_1.Flex, { justify: "center" },
|
|
690
770
|
react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 20, vertical: true, align: "end", style: { width: "100%", maxWidth: "900px" } },
|
|
@@ -699,8 +779,8 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
699
779
|
react_1.default.createElement(antd_1.Flex, { justify: "center" },
|
|
700
780
|
react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 60, justify: "end", align: "end", style: { width: "100%", maxWidth: "900px" } },
|
|
701
781
|
isBackButtonVisible && (react_1.default.createElement(antd_1.Button, { onClick: handlePrevStep, size: "large", block: true },
|
|
702
|
-
react_1.default.createElement(icons_1.ArrowLeftOutlined, null), (
|
|
703
|
-
|
|
782
|
+
react_1.default.createElement(icons_1.ArrowLeftOutlined, null), (_h = items[activeStep - 1]) === null || _h === void 0 ? void 0 :
|
|
783
|
+
_h.title)),
|
|
704
784
|
isNextStepVisible ? (react_1.default.createElement(antd_1.Tooltip, { title: missingRequiredDataTooltip },
|
|
705
785
|
react_1.default.createElement(antd_1.Button, { onClick: handleNextStep, type: "primary", size: "large", style: { maxWidth: "50%" }, disabled: isNextStepDisabled, block: true },
|
|
706
786
|
intl.formatMessage(exports.translationMessages.createInvoice_nextStep),
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.component_header {
|
|
2
|
+
height: 3.3em;
|
|
3
|
+
background-color: #fff;
|
|
4
|
+
border-bottom: solid 1px #d9d9d9;
|
|
5
|
+
border-radius: 4px 4px 0 0;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
padding: 1em 2em;
|
|
10
|
+
}
|
|
11
|
+
.component_header_title {
|
|
12
|
+
font-size: 1.1em;
|
|
13
|
+
}
|
|
14
|
+
.component_header_title > span > i {
|
|
15
|
+
font-size: 20px;
|
|
16
|
+
}
|
|
17
|
+
.header_icon {
|
|
18
|
+
font-size: 1.5em;
|
|
19
|
+
margin-right: 0.75em;
|
|
20
|
+
color: #1890ff;
|
|
21
|
+
}
|
|
22
|
+
.header_right {
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: flex-end;
|
|
25
|
+
}
|
|
26
|
+
@media screen and (max-width: 768px) {
|
|
27
|
+
.header_right {
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
.header_right > button {
|
|
32
|
+
margin-bottom: unset !important;
|
|
33
|
+
}
|
|
34
|
+
.component_body {
|
|
35
|
+
border-radius: 0 0 4px 4px;
|
|
36
|
+
}
|
|
37
|
+
.component_wrapper {
|
|
38
|
+
align-self: stretch;
|
|
39
|
+
height: 100%;
|
|
40
|
+
background-color: #fff;
|
|
41
|
+
border: solid 1px #d9d9d9;
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
}
|
|
44
|
+
.component_wrapper_padding {
|
|
45
|
+
padding: 1em;
|
|
46
|
+
}
|
|
47
|
+
.umz_noValidationMessage .ant-form-item-explain {
|
|
48
|
+
height: 20px !important;
|
|
49
|
+
visibility: hidden !important;
|
|
50
|
+
}
|
|
51
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -93,12 +93,14 @@
|
|
|
93
93
|
"createInvoice_SendCopyTooltipDisabled": "You must fill in your email address to send yourself a copy",
|
|
94
94
|
"createInvoice_Submit": "Submit",
|
|
95
95
|
"createInvoice_addDocumentLineMsg": "At least one document line",
|
|
96
|
+
"createInvoice_attachmentsNotRestored": "You logged in again: please add the attachments again.",
|
|
96
97
|
"createInvoice_customerStepTitle": "Customer",
|
|
97
98
|
"createInvoice_invoiceHadValidationErrors": "Created invoice had validation errors",
|
|
98
99
|
"createInvoice_invoiceStepTitle": "Invoice",
|
|
99
100
|
"createInvoice_nextStep": "Next step",
|
|
100
101
|
"createInvoice_paymentStepTitle": "Payment",
|
|
101
102
|
"createInvoice_selectCustomerMsg": "Customer must be selected",
|
|
103
|
+
"createInvoice_sessionExpired": "Your login has expired. Log in again to continue.",
|
|
102
104
|
"createInvoice_successfullySubmittedInvoiceMsg": "Successfully submitted the invoice",
|
|
103
105
|
"createInvoice_successfullyUploadedAttachmentMsg": "Successfully uploaded attachment {attachment}",
|
|
104
106
|
"createInvoice_supplierStepTitle": "Supplier",
|
|
@@ -130,6 +132,10 @@
|
|
|
130
132
|
"invoicePreview_billingLinesTitle": "Invoice lines",
|
|
131
133
|
"invoicePreview_lineDiscount": "line discount",
|
|
132
134
|
"invoicePreview_paymentInfoTitle": "Payment information",
|
|
135
|
+
"invoicePreview_roleGranted": "power of attorney",
|
|
136
|
+
"invoicePreview_roleProcuration": "procuration holder",
|
|
137
|
+
"invoicePreview_roleSelf": "on own behalf",
|
|
138
|
+
"invoicePreview_sentBy": "Sent by {name} ({role})",
|
|
133
139
|
"missingRequiredData": "Missing required data:",
|
|
134
140
|
"noWhitespaceValidation_message": "This field cannot be empty or just spaces",
|
|
135
141
|
"paymentMethod_label": "Account number",
|
|
@@ -154,6 +160,23 @@
|
|
|
154
160
|
"referenceIdentifiers_labels_referenceIdentifier_title": "An identifier for an object on which the invoice is based, given by the seller. It may be a subscription number, telephone number, meter point, vehicle, person etc., as applicable.",
|
|
155
161
|
"referenceIdentifiers_values_validation_message": "This value doesn't exist",
|
|
156
162
|
"saveInformation_label": "Save information",
|
|
163
|
+
"sendOnBehalf_company": "On behalf of a company",
|
|
164
|
+
"sendOnBehalf_companyIdentifier": "Company registration number",
|
|
165
|
+
"sendOnBehalf_granted": "You hold a power of attorney for this company",
|
|
166
|
+
"sendOnBehalf_grantedTag": "Power of attorney",
|
|
167
|
+
"sendOnBehalf_lookup": "Look up",
|
|
168
|
+
"sendOnBehalf_lostTag": "No longer authorised",
|
|
169
|
+
"sendOnBehalf_notAllowed": "You are neither a holder of procuration nor hold a power of attorney for {name}. Ask a holder of procuration to grant you one.",
|
|
170
|
+
"sendOnBehalf_notFound": "The company was not found in the company register",
|
|
171
|
+
"sendOnBehalf_otherCompany": "Enter another registration number…",
|
|
172
|
+
"sendOnBehalf_procuration": "Holder of procuration according to the company register",
|
|
173
|
+
"sendOnBehalf_procurationTag": "Procuration holder",
|
|
174
|
+
"sendOnBehalf_selectCompany": "Select a company",
|
|
175
|
+
"sendOnBehalf_self": "Myself (sole trader / contractor)",
|
|
176
|
+
"sendOnBehalf_title": "On whose behalf are you sending the invoice?",
|
|
177
|
+
"sessionBar_change": "Change",
|
|
178
|
+
"sessionBar_delegations": "Powers of attorney",
|
|
179
|
+
"sessionBar_onBehalfOf": "on behalf of {seller}",
|
|
157
180
|
"submitConfirmation_SuccessfullyUploadedAttachment": "Successfully uploaded attachment:",
|
|
158
181
|
"submitConfirmation_attachmentFailedToUpload": "Attachment failed to upload:",
|
|
159
182
|
"submitConfirmation_createAnotherDocuments_buttonLabel": "Create another document",
|
|
@@ -93,12 +93,14 @@
|
|
|
93
93
|
"createInvoice_SendCopyTooltipDisabled": "Netfang þarf að fyllast út til þess að hægt sé að senda þér afrit",
|
|
94
94
|
"createInvoice_Submit": "Senda",
|
|
95
95
|
"createInvoice_addDocumentLineMsg": "Bætið við a.m.k einnig línu í skrá",
|
|
96
|
+
"createInvoice_attachmentsNotRestored": "Þú skráðir þig inn aftur: bættu viðhengjunum við aftur.",
|
|
96
97
|
"createInvoice_customerStepTitle": "Kaupandi",
|
|
97
98
|
"createInvoice_invoiceHadValidationErrors": "Reikningur hefur sannreyningarvillurs",
|
|
98
99
|
"createInvoice_invoiceStepTitle": "Reikningur",
|
|
99
100
|
"createInvoice_nextStep": "Halda áfram",
|
|
100
101
|
"createInvoice_paymentStepTitle": "Greiðsluháttur",
|
|
101
102
|
"createInvoice_selectCustomerMsg": "Viðskiptavinur verður að vera valinn",
|
|
103
|
+
"createInvoice_sessionExpired": "Innskráningin þín er runnin út. Skráðu þig inn aftur til að halda áfram.",
|
|
102
104
|
"createInvoice_successfullySubmittedInvoiceMsg": "Sending reiknings tókst",
|
|
103
105
|
"createInvoice_successfullyUploadedAttachmentMsg": "Það tókst að hlaða upp viðhenginu {attachment}",
|
|
104
106
|
"createInvoice_supplierStepTitle": "Þínar upplýsingar",
|
|
@@ -130,6 +132,10 @@
|
|
|
130
132
|
"invoicePreview_billingLinesTitle": "Reikningslínur",
|
|
131
133
|
"invoicePreview_lineDiscount": "afsláttur á línu",
|
|
132
134
|
"invoicePreview_paymentInfoTitle": "Greiðsluupplýsingar",
|
|
135
|
+
"invoicePreview_roleGranted": "umboð",
|
|
136
|
+
"invoicePreview_roleProcuration": "prókúruhafi",
|
|
137
|
+
"invoicePreview_roleSelf": "eigin hönd",
|
|
138
|
+
"invoicePreview_sentBy": "Sent af {name} ({role})",
|
|
133
139
|
"missingRequiredData": "Vantar skilyrt gögn:",
|
|
134
140
|
"noWhitespaceValidation_message": "Þetta svæði má ekki innihalda eingöngu stafbil",
|
|
135
141
|
"paymentMethod_label": "Reikningsnúmer",
|
|
@@ -154,6 +160,23 @@
|
|
|
154
160
|
"referenceIdentifiers_labels_referenceIdentifier_title": "Tilvísun í viðfang sem tengt er reikningi, gefið upp af seljanda. Gæti verið áskriftarnúmer, símanúmer, mælistaður, ökutæki, einstaklingur o.fl. eftir því sem við á.",
|
|
155
161
|
"referenceIdentifiers_values_validation_message": "Þetta gildi er ekki til",
|
|
156
162
|
"saveInformation_label": "Vista upplýsingar",
|
|
163
|
+
"sendOnBehalf_company": "Fyrir hönd fyrirtækis",
|
|
164
|
+
"sendOnBehalf_companyIdentifier": "Kennitala fyrirtækis",
|
|
165
|
+
"sendOnBehalf_granted": "Þú hefur umboð fyrir þetta félag",
|
|
166
|
+
"sendOnBehalf_grantedTag": "Umboð",
|
|
167
|
+
"sendOnBehalf_lookup": "Fletta upp",
|
|
168
|
+
"sendOnBehalf_lostTag": "Ekki lengur heimild",
|
|
169
|
+
"sendOnBehalf_notAllowed": "Þú ert hvorki prókúruhafi né með umboð fyrir {name}. Biddu prókúruhafa að veita þér umboð.",
|
|
170
|
+
"sendOnBehalf_notFound": "Fyrirtækið fannst ekki í fyrirtækjaskrá",
|
|
171
|
+
"sendOnBehalf_otherCompany": "Slá inn aðra kennitölu…",
|
|
172
|
+
"sendOnBehalf_procuration": "Prókúruhafi skv. fyrirtækjaskrá Skattsins",
|
|
173
|
+
"sendOnBehalf_procurationTag": "Prókúruhafi",
|
|
174
|
+
"sendOnBehalf_selectCompany": "Veldu fyrirtæki",
|
|
175
|
+
"sendOnBehalf_self": "Eigin hönd (einyrki / verktaki)",
|
|
176
|
+
"sendOnBehalf_title": "Fyrir hönd hvers sendir þú reikninginn?",
|
|
177
|
+
"sessionBar_change": "Breyta",
|
|
178
|
+
"sessionBar_delegations": "Umboð",
|
|
179
|
+
"sessionBar_onBehalfOf": "f.h. {seller}",
|
|
157
180
|
"submitConfirmation_SuccessfullyUploadedAttachment": "Viðhengi sem hefur verið sent:",
|
|
158
181
|
"submitConfirmation_attachmentFailedToUpload": "Ekki tókst að hlaða upp viðhengi:",
|
|
159
182
|
"submitConfirmation_createAnotherDocuments_buttonLabel": "Búa til annað skjal",
|
|
@@ -94,12 +94,14 @@ declare const _default: {
|
|
|
94
94
|
createInvoice_SendCopyTooltipDisabled: string;
|
|
95
95
|
createInvoice_Submit: string;
|
|
96
96
|
createInvoice_addDocumentLineMsg: string;
|
|
97
|
+
createInvoice_attachmentsNotRestored: string;
|
|
97
98
|
createInvoice_customerStepTitle: string;
|
|
98
99
|
createInvoice_invoiceHadValidationErrors: string;
|
|
99
100
|
createInvoice_invoiceStepTitle: string;
|
|
100
101
|
createInvoice_nextStep: string;
|
|
101
102
|
createInvoice_paymentStepTitle: string;
|
|
102
103
|
createInvoice_selectCustomerMsg: string;
|
|
104
|
+
createInvoice_sessionExpired: string;
|
|
103
105
|
createInvoice_successfullySubmittedInvoiceMsg: string;
|
|
104
106
|
createInvoice_successfullyUploadedAttachmentMsg: string;
|
|
105
107
|
createInvoice_supplierStepTitle: string;
|
|
@@ -131,6 +133,10 @@ declare const _default: {
|
|
|
131
133
|
invoicePreview_billingLinesTitle: string;
|
|
132
134
|
invoicePreview_lineDiscount: string;
|
|
133
135
|
invoicePreview_paymentInfoTitle: string;
|
|
136
|
+
invoicePreview_roleGranted: string;
|
|
137
|
+
invoicePreview_roleProcuration: string;
|
|
138
|
+
invoicePreview_roleSelf: string;
|
|
139
|
+
invoicePreview_sentBy: string;
|
|
134
140
|
missingRequiredData: string;
|
|
135
141
|
noWhitespaceValidation_message: string;
|
|
136
142
|
paymentMethod_label: string;
|
|
@@ -155,6 +161,23 @@ declare const _default: {
|
|
|
155
161
|
referenceIdentifiers_labels_referenceIdentifier_title: string;
|
|
156
162
|
referenceIdentifiers_values_validation_message: string;
|
|
157
163
|
saveInformation_label: string;
|
|
164
|
+
sendOnBehalf_company: string;
|
|
165
|
+
sendOnBehalf_companyIdentifier: string;
|
|
166
|
+
sendOnBehalf_granted: string;
|
|
167
|
+
sendOnBehalf_grantedTag: string;
|
|
168
|
+
sendOnBehalf_lookup: string;
|
|
169
|
+
sendOnBehalf_lostTag: string;
|
|
170
|
+
sendOnBehalf_notAllowed: string;
|
|
171
|
+
sendOnBehalf_notFound: string;
|
|
172
|
+
sendOnBehalf_otherCompany: string;
|
|
173
|
+
sendOnBehalf_procuration: string;
|
|
174
|
+
sendOnBehalf_procurationTag: string;
|
|
175
|
+
sendOnBehalf_selectCompany: string;
|
|
176
|
+
sendOnBehalf_self: string;
|
|
177
|
+
sendOnBehalf_title: string;
|
|
178
|
+
sessionBar_change: string;
|
|
179
|
+
sessionBar_delegations: string;
|
|
180
|
+
sessionBar_onBehalfOf: string;
|
|
158
181
|
submitConfirmation_SuccessfullyUploadedAttachment: string;
|
|
159
182
|
submitConfirmation_attachmentFailedToUpload: string;
|
|
160
183
|
submitConfirmation_createAnotherDocuments_buttonLabel: string;
|
|
@@ -304,12 +327,14 @@ declare const _default: {
|
|
|
304
327
|
createInvoice_SendCopyTooltipDisabled: string;
|
|
305
328
|
createInvoice_Submit: string;
|
|
306
329
|
createInvoice_addDocumentLineMsg: string;
|
|
330
|
+
createInvoice_attachmentsNotRestored: string;
|
|
307
331
|
createInvoice_customerStepTitle: string;
|
|
308
332
|
createInvoice_invoiceHadValidationErrors: string;
|
|
309
333
|
createInvoice_invoiceStepTitle: string;
|
|
310
334
|
createInvoice_nextStep: string;
|
|
311
335
|
createInvoice_paymentStepTitle: string;
|
|
312
336
|
createInvoice_selectCustomerMsg: string;
|
|
337
|
+
createInvoice_sessionExpired: string;
|
|
313
338
|
createInvoice_successfullySubmittedInvoiceMsg: string;
|
|
314
339
|
createInvoice_successfullyUploadedAttachmentMsg: string;
|
|
315
340
|
createInvoice_supplierStepTitle: string;
|
|
@@ -341,6 +366,10 @@ declare const _default: {
|
|
|
341
366
|
invoicePreview_billingLinesTitle: string;
|
|
342
367
|
invoicePreview_lineDiscount: string;
|
|
343
368
|
invoicePreview_paymentInfoTitle: string;
|
|
369
|
+
invoicePreview_roleGranted: string;
|
|
370
|
+
invoicePreview_roleProcuration: string;
|
|
371
|
+
invoicePreview_roleSelf: string;
|
|
372
|
+
invoicePreview_sentBy: string;
|
|
344
373
|
missingRequiredData: string;
|
|
345
374
|
noWhitespaceValidation_message: string;
|
|
346
375
|
paymentMethod_label: string;
|
|
@@ -365,6 +394,23 @@ declare const _default: {
|
|
|
365
394
|
referenceIdentifiers_labels_referenceIdentifier_title: string;
|
|
366
395
|
referenceIdentifiers_values_validation_message: string;
|
|
367
396
|
saveInformation_label: string;
|
|
397
|
+
sendOnBehalf_company: string;
|
|
398
|
+
sendOnBehalf_companyIdentifier: string;
|
|
399
|
+
sendOnBehalf_granted: string;
|
|
400
|
+
sendOnBehalf_grantedTag: string;
|
|
401
|
+
sendOnBehalf_lookup: string;
|
|
402
|
+
sendOnBehalf_lostTag: string;
|
|
403
|
+
sendOnBehalf_notAllowed: string;
|
|
404
|
+
sendOnBehalf_notFound: string;
|
|
405
|
+
sendOnBehalf_otherCompany: string;
|
|
406
|
+
sendOnBehalf_procuration: string;
|
|
407
|
+
sendOnBehalf_procurationTag: string;
|
|
408
|
+
sendOnBehalf_selectCompany: string;
|
|
409
|
+
sendOnBehalf_self: string;
|
|
410
|
+
sendOnBehalf_title: string;
|
|
411
|
+
sessionBar_change: string;
|
|
412
|
+
sessionBar_delegations: string;
|
|
413
|
+
sessionBar_onBehalfOf: string;
|
|
368
414
|
submitConfirmation_SuccessfullyUploadedAttachment: string;
|
|
369
415
|
submitConfirmation_attachmentFailedToUpload: string;
|
|
370
416
|
submitConfirmation_createAnotherDocuments_buttonLabel: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BusinessEntity, BusinessEntityCollectionResource } from "@unimaze/api-clients/lib/rapi/api";
|
|
1
2
|
import { ImportDocumentValidationData, MessageOutput, InvoiceMetadataInput, TransactionProcessingMode } from "@unimaze/api-clients/lib/mapi";
|
|
2
3
|
import { AxiosPromise, CancelToken } from "axios";
|
|
3
4
|
import { LanguageProp } from "../common/types/CommonProps";
|
|
@@ -20,7 +21,13 @@ interface AttachDocument {
|
|
|
20
21
|
declare const submitDocument: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey?: string) => AxiosPromise<MessageOutput>;
|
|
21
22
|
declare const submitDocumentFetch: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, token: string) => Promise<Response>;
|
|
22
23
|
declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, token: string, callName?: string, language?: LanguageProp) => AxiosPromise<ImportDocumentValidationData[] | MessageOutput>;
|
|
23
|
-
declare const getAuthToken: (rapiBaseUrl: string, entityIsoIdentifier: string) => AxiosPromise<string>;
|
|
24
|
+
declare const getAuthToken: (rapiBaseUrl: string, entityIsoIdentifier: string, accessToken?: string, sellerIsoIdentifier?: string) => AxiosPromise<string>;
|
|
25
|
+
/** A business entity from RAPI, as seen by the logged-in person (callerRoles = their own roles for it) */
|
|
26
|
+
declare const getBusinessEntity: (rapiBaseUrl: string, isoIdentifier: string, accessToken: string) => AxiosPromise<BusinessEntity>;
|
|
27
|
+
/** Companies the logged-in person holds procuration or a delegation for, each re-checked by RAPI; a lost company comes back once with no callerRoles */
|
|
28
|
+
declare const getRepresentedCompanies: (rapiBaseUrl: string, accessToken: string) => Promise<BusinessEntityCollectionResource[]>;
|
|
29
|
+
/** True when RAPI refused the IdentityServer token (expired or invalid): the person must log in again */
|
|
30
|
+
declare const isUnauthorized: (error: any) => boolean;
|
|
24
31
|
declare const getCancelToken: (callName: string, showMessage?: boolean) => CancelToken;
|
|
25
32
|
declare const submitAttachmentIfAnyLeft: (_messageId: string, _attachments: AttachmentProps[], _mapiBaseUrl: string, token: string, intl: IntlShape, numberOfAttemptedCalls: number, setNumberOfAttemptedCalls: (numberOfAttemptedCalls: number) => void, numberOfFailedAttempts: number[], allAttachmentsWithStatuses: AttachmentProps[], setAllAttachmentsWithStatuses: (allNewAttachments: AttachmentProps[]) => void) => void;
|
|
26
|
-
export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch, submitAttachmentIfAnyLeft, getAuthToken, getCancelToken };
|
|
33
|
+
export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch, submitAttachmentIfAnyLeft, getAuthToken, getBusinessEntity, getRepresentedCompanies, isUnauthorized, getCancelToken };
|
package/lib/utils/ApiUtility.js
CHANGED
|
@@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.getCancelToken = exports.getAuthToken = exports.submitAttachmentIfAnyLeft = exports.submitDocumentFetch = exports.submitDocument = exports.submitInvoice = void 0;
|
|
62
|
+
exports.getCancelToken = exports.isUnauthorized = exports.getRepresentedCompanies = exports.getBusinessEntity = exports.getAuthToken = exports.submitAttachmentIfAnyLeft = exports.submitDocumentFetch = exports.submitDocument = exports.submitInvoice = void 0;
|
|
63
63
|
var api_clients_1 = require("@unimaze/api-clients");
|
|
64
64
|
var api_1 = require("@unimaze/api-clients/lib/rapi/api");
|
|
65
65
|
var mapi_1 = require("@unimaze/api-clients/lib/mapi");
|
|
@@ -89,6 +89,15 @@ var initialiseRapiPortalApi = function (rapiBaseUrl) {
|
|
|
89
89
|
var initiatedConfig = new mapi_1.Configuration(apiConfig);
|
|
90
90
|
return new api_1.PortalApi(initiatedConfig);
|
|
91
91
|
};
|
|
92
|
+
var initialiseRapiBusinessEntityApi = function (rapiBaseUrl) {
|
|
93
|
+
var apiConfig = {
|
|
94
|
+
basePath: rapiBaseUrl,
|
|
95
|
+
};
|
|
96
|
+
var initiatedConfig = new mapi_1.Configuration(apiConfig);
|
|
97
|
+
return new api_1.BusinessEntityApi(initiatedConfig);
|
|
98
|
+
};
|
|
99
|
+
/** The generated RAPI client does not add the IdentityServer bearer token itself */
|
|
100
|
+
var bearerOptions = function (accessToken) { return ({ headers: { Authorization: "Bearer ".concat(accessToken) } }); };
|
|
92
101
|
var submitDocument = function (data, attachDocument, mapiBaseUrl, apiKey) {
|
|
93
102
|
var messageId = attachDocument.messageId, name = attachDocument.name, contentType = attachDocument.contentType, more = attachDocument.more;
|
|
94
103
|
var headers = __assign(__assign({}, (apiKey && { Authorization: "Bearer ".concat(window.btoa(apiKey)) })), { "Content-Type": "application/octet-stream", "X-test": "test" });
|
|
@@ -171,11 +180,29 @@ var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, token, callName,
|
|
|
171
180
|
return transactionApi.createSubmitInvoice(messageId, more, conversationIdentifier, processingMode, services, undefined, invoiceMetadataInput, createOptions(token, callName, language));
|
|
172
181
|
};
|
|
173
182
|
exports.submitInvoice = submitInvoice;
|
|
174
|
-
var getAuthToken = function (rapiBaseUrl, entityIsoIdentifier) {
|
|
183
|
+
var getAuthToken = function (rapiBaseUrl, entityIsoIdentifier, accessToken, sellerIsoIdentifier) {
|
|
175
184
|
var portalApi = initialiseRapiPortalApi(rapiBaseUrl);
|
|
176
|
-
|
|
185
|
+
// portal with login: RAPI checks that the logged-in person may send for the seller
|
|
186
|
+
return portalApi.portalAuthenticate(entityIsoIdentifier, accessToken ? sellerIsoIdentifier : undefined, accessToken ? bearerOptions(accessToken) : undefined);
|
|
177
187
|
};
|
|
178
188
|
exports.getAuthToken = getAuthToken;
|
|
189
|
+
/** A business entity from RAPI, as seen by the logged-in person (callerRoles = their own roles for it) */
|
|
190
|
+
var getBusinessEntity = function (rapiBaseUrl, isoIdentifier, accessToken) {
|
|
191
|
+
var businessEntityApi = initialiseRapiBusinessEntityApi(rapiBaseUrl);
|
|
192
|
+
return businessEntityApi.getByIsoIdentifier(isoIdentifier, bearerOptions(accessToken));
|
|
193
|
+
};
|
|
194
|
+
exports.getBusinessEntity = getBusinessEntity;
|
|
195
|
+
/** Companies the logged-in person holds procuration or a delegation for, each re-checked by RAPI; a lost company comes back once with no callerRoles */
|
|
196
|
+
var getRepresentedCompanies = function (rapiBaseUrl, accessToken) {
|
|
197
|
+
var businessEntityApi = initialiseRapiBusinessEntityApi(rapiBaseUrl);
|
|
198
|
+
return businessEntityApi
|
|
199
|
+
.getCompaniesAsync(undefined, undefined, undefined, "me", undefined, undefined, undefined, bearerOptions(accessToken))
|
|
200
|
+
.then(function (response) { var _a; return (_a = response.data.value) !== null && _a !== void 0 ? _a : []; });
|
|
201
|
+
};
|
|
202
|
+
exports.getRepresentedCompanies = getRepresentedCompanies;
|
|
203
|
+
/** True when RAPI refused the IdentityServer token (expired or invalid): the person must log in again */
|
|
204
|
+
var isUnauthorized = function (error) { var _a; return ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 401; };
|
|
205
|
+
exports.isUnauthorized = isUnauthorized;
|
|
179
206
|
var createOptions = function (apiKey, callName, language) {
|
|
180
207
|
return __assign({ headers: {
|
|
181
208
|
"Accept-Language": language ? language : "en",
|