@unimaze/billing 0.13.1 → 0.14.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.
|
@@ -22,6 +22,7 @@ var icons_1 = require("@ant-design/icons");
|
|
|
22
22
|
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
23
23
|
var OrderReference_1 = __importDefault(require("./OrderReference"));
|
|
24
24
|
var AccountingCost_1 = __importDefault(require("./AccountingCost"));
|
|
25
|
+
var react_1 = require("react");
|
|
25
26
|
var translationMessages = react_intl_1.defineMessages({
|
|
26
27
|
baseInformation_title: {
|
|
27
28
|
id: "baseInformation_title",
|
|
@@ -97,6 +98,11 @@ var translationMessages = react_intl_1.defineMessages({
|
|
|
97
98
|
},
|
|
98
99
|
});
|
|
99
100
|
var BaseInformation = function (props) {
|
|
101
|
+
var _a = react_1.useState(), dueDateDefaultPickerValue = _a[0], setDueDateDefaultPickerValue = _a[1];
|
|
102
|
+
react_1.useEffect(function () {
|
|
103
|
+
var a = getDueDateLimit(props.form.getFieldValue(["invoice", "issueDate"]), props.dueDateMinimumOffset);
|
|
104
|
+
setDueDateDefaultPickerValue(a);
|
|
105
|
+
}, [props.form.getFieldValue(["invoice", "issueDate"])]);
|
|
100
106
|
var getCurrencies = function (recRequirements) {
|
|
101
107
|
var currencies = [
|
|
102
108
|
{
|
|
@@ -136,15 +142,19 @@ var BaseInformation = function (props) {
|
|
|
136
142
|
return currencies;
|
|
137
143
|
}
|
|
138
144
|
};
|
|
145
|
+
var getDueDateLimit = function (issueDate, dueDateMinimumOffset) {
|
|
146
|
+
var dueDateLimit;
|
|
147
|
+
if (issueDate) {
|
|
148
|
+
dueDateLimit = moment_1.default.max(moment_1.default().startOf("day").add(dueDateMinimumOffset, "days"), issueDate.startOf("day"));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
dueDateLimit = moment_1.default().startOf("day").add(dueDateMinimumOffset, "days");
|
|
152
|
+
}
|
|
153
|
+
return dueDateLimit;
|
|
154
|
+
};
|
|
139
155
|
var disabledDate = function (dueDate, issueDate, dueDateMinimumOffset) {
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
? issueDate.clone().startOf("day")
|
|
143
|
-
: moment_1.default().startOf("day")
|
|
144
|
-
: moment_1.default().startOf("day");
|
|
145
|
-
// const baseDate = moment().startOf("day");
|
|
146
|
-
var addedDate = dueDateMinimumOffset ? baseDate.add(dueDateMinimumOffset, "days") : baseDate;
|
|
147
|
-
return dueDate < addedDate;
|
|
156
|
+
var dueDateLimit = getDueDateLimit(issueDate, dueDateMinimumOffset);
|
|
157
|
+
return dueDate < dueDateLimit;
|
|
148
158
|
};
|
|
149
159
|
var checkIfEmpty = function (date) {
|
|
150
160
|
if (!date) {
|
|
@@ -178,7 +188,11 @@ var BaseInformation = function (props) {
|
|
|
178
188
|
React.createElement(antd_1.Input, null)),
|
|
179
189
|
React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.issueDate, defaultLabel: issueDateLabelNode, defaultIsRequired: true, fieldName: ["invoice", "issueDate"] },
|
|
180
190
|
React.createElement(antd_1.DatePicker, { style: { width: "100%" }, format: "DD.MM.YYYY" })),
|
|
181
|
-
React.createElement(form_item_1.default
|
|
191
|
+
React.createElement(form_item_1.default
|
|
192
|
+
// dependencies={[["invoice", "issueDate"]]}
|
|
193
|
+
, {
|
|
194
|
+
// dependencies={[["invoice", "issueDate"]]}
|
|
195
|
+
receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.dueDate, defaultLabel: dueDateLabelNode, defaultIsRequired: true, fieldName: ["invoice", "dueDate"], additionalRules: [
|
|
182
196
|
{
|
|
183
197
|
validator: (function (rule, value, callback) {
|
|
184
198
|
if (!value) {
|
|
@@ -191,10 +205,10 @@ var BaseInformation = function (props) {
|
|
|
191
205
|
}),
|
|
192
206
|
},
|
|
193
207
|
] },
|
|
194
|
-
React.createElement(antd_1.DatePicker, { style: { width: "100%" }, format: "DD.MM.YYYY", onChange: checkIfEmpty, disabledDate: (function (current) {
|
|
208
|
+
React.createElement(antd_1.DatePicker, { defaultPickerValue: dueDateDefaultPickerValue, style: { width: "100%" }, format: "DD.MM.YYYY", onChange: checkIfEmpty, getPopupContainer: function (trigger) { return trigger.parentElement; }, disabledDate: (function (current) {
|
|
195
209
|
var currentDate = current;
|
|
196
|
-
var issueDate = props.form.getFieldValue(["invoice", "issueDate"]);
|
|
197
210
|
var dueDateMinimumOffset = props.dueDateMinimumOffset;
|
|
211
|
+
var issueDate = props.form.getFieldValue(["invoice", "issueDate"]);
|
|
198
212
|
return disabledDate(currentDate, issueDate, dueDateMinimumOffset);
|
|
199
213
|
}) })),
|
|
200
214
|
React.createElement(OrderReference_1.default, { receiverRequirements: props.receiverRequirements, formInstance: props.form, dependencies: [["invoice", "buyerReference"]] }),
|
|
@@ -31,9 +31,9 @@ var utils_1 = require("../utils");
|
|
|
31
31
|
var BillingLineUtility_1 = require("../utils/BillingLineUtility");
|
|
32
32
|
var paymentMethodForConversion_1 = require("../common/components/payment-method/paymentMethodForConversion");
|
|
33
33
|
var uuid_1 = require("uuid");
|
|
34
|
-
var react_google_recaptcha_1 = __importDefault(require("react-google-recaptcha"));
|
|
35
34
|
var ApiUtility_1 = require("../utils/ApiUtility");
|
|
36
35
|
var ConversionUtility_1 = require("../utils/ConversionUtility");
|
|
36
|
+
var reaptcha_1 = __importDefault(require("reaptcha"));
|
|
37
37
|
var translationMessages = react_intl_1.defineMessages({
|
|
38
38
|
createInvoice_addDocumentLineMsg: {
|
|
39
39
|
id: "createInvoice_addDocumentLineMsg",
|
|
@@ -59,6 +59,18 @@ var translationMessages = react_intl_1.defineMessages({
|
|
|
59
59
|
id: "createInvoice_Submit",
|
|
60
60
|
defaultMessage: "Submit"
|
|
61
61
|
},
|
|
62
|
+
createInvoice_SendCopy: {
|
|
63
|
+
id: "createInvoice_SendCopy",
|
|
64
|
+
defaultMessage: "Send a copy"
|
|
65
|
+
},
|
|
66
|
+
createInvoice_SendCopyTooltip: {
|
|
67
|
+
id: "createInvoice_SendCopyTooltip",
|
|
68
|
+
defaultMessage: "Sends you a PDF copy of the invoice"
|
|
69
|
+
},
|
|
70
|
+
createInvoice_SendCopyTooltipDisabled: {
|
|
71
|
+
id: "createInvoice_SendCopyTooltipDisabled",
|
|
72
|
+
defaultMessage: "You must fill in your email address to send yourself a copy"
|
|
73
|
+
},
|
|
62
74
|
});
|
|
63
75
|
/**
|
|
64
76
|
* Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
|
|
@@ -73,17 +85,23 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
73
85
|
var _b = react_1.useState(true), isSubmitDisabled = _b[0], setIsSubmitDisabled = _b[1];
|
|
74
86
|
var _c = react_1.useState(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0])), chosenCustomer = _c[0], setChosenCustomer = _c[1];
|
|
75
87
|
var _d = react_1.useState(props.customers[0].apiKey), chosenCustomerApiKey = _d[0], setChosenCustomerApiKey = _d[1];
|
|
76
|
-
var _e = react_1.
|
|
88
|
+
var _e = react_1.useState(true), sendCopyDisabled = _e[0], setSendCopyDisabled = _e[1];
|
|
89
|
+
var _f = react_1.useState(false), sendCopy = _f[0], setSendCopy = _f[1];
|
|
90
|
+
var _g = react_1.default.useState(""), referenceIdentifierValidateStatus = _g[0], setReferenceIdentifierValidateStatus = _g[1];
|
|
77
91
|
// const [billingLinesEditableIndex, setBillingLinesEditableIndex] = useState<number>(1)
|
|
78
|
-
var
|
|
92
|
+
var _h = react_1.useState(false), outsideVatScope = _h[0], setOutsideVatScope = _h[1];
|
|
93
|
+
var _j = react_1.useState(false), captchaVerified = _j[0], setCaptchaVerified = _j[1];
|
|
94
|
+
react_1.useEffect(function () {
|
|
95
|
+
setIsSubmitDisabled(!captchaVerified);
|
|
96
|
+
}, [captchaVerified]);
|
|
79
97
|
// attachments
|
|
80
98
|
// TODO: remove the states, set the values to the form in attachment components
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
99
|
+
var _k = react_1.useState([]), file1 = _k[0], setFile1 = _k[1];
|
|
100
|
+
var _l = react_1.useState(""), attachmentFieldValidation1 = _l[0], setAttachmentFieldValidation1 = _l[1];
|
|
101
|
+
var _m = react_1.useState([]), file2 = _m[0], setFile2 = _m[1];
|
|
102
|
+
var _o = react_1.useState(""), attachmentFieldValidation2 = _o[0], setAttachmentFieldValidation2 = _o[1];
|
|
103
|
+
var _p = react_1.useState([]), file3 = _p[0], setFile3 = _p[1];
|
|
104
|
+
var _q = react_1.useState(""), attachmentFieldValidation3 = _q[0], setAttachmentFieldValidation3 = _q[1];
|
|
87
105
|
react_1.useEffect(function () {
|
|
88
106
|
form.resetFields([
|
|
89
107
|
["invoice", "supplier", "vatNumber"],
|
|
@@ -115,6 +133,24 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
115
133
|
setFile3([]);
|
|
116
134
|
setAttachmentFieldValidation3("");
|
|
117
135
|
};
|
|
136
|
+
var supplierEmailValue = form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]);
|
|
137
|
+
react_1.useEffect(function () {
|
|
138
|
+
if (supplierEmailValue) {
|
|
139
|
+
form.validateFields([["invoice", "supplier", "contact", "electronicMail"]])
|
|
140
|
+
.then(function (v) {
|
|
141
|
+
setSendCopyDisabled(!supplierEmailValue);
|
|
142
|
+
setSendCopy(true);
|
|
143
|
+
})
|
|
144
|
+
.catch(function (e) {
|
|
145
|
+
setSendCopyDisabled(true);
|
|
146
|
+
setSendCopy(false);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
setSendCopy(false);
|
|
151
|
+
setSendCopyDisabled(true);
|
|
152
|
+
}
|
|
153
|
+
}, [supplierEmailValue]);
|
|
118
154
|
var handleSubmit = function (values) {
|
|
119
155
|
// console.log("values at the start of submit", values);
|
|
120
156
|
setSubmitting(true);
|
|
@@ -136,12 +172,16 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
136
172
|
setSubmitting(false);
|
|
137
173
|
return;
|
|
138
174
|
}
|
|
175
|
+
var services = sendCopy
|
|
176
|
+
? ["urn:services:dispatcher:mail.pdf?email=" + supplierEmailValue]
|
|
177
|
+
: undefined;
|
|
139
178
|
var invoiceMetadataInput = utils_1.convertToInvoiceMetadataInput(values, BillingLineUtility_1.billingLinesFieldsMetadata(form), paymentMethodForConversion_1.PaymentMethodFormData(values), chosenCustomer);
|
|
140
179
|
var createSubmitInvoice = {
|
|
141
180
|
invoiceMetadataInput: invoiceMetadataInput,
|
|
142
181
|
more: attachments.length > 0,
|
|
143
182
|
messageId: uuid_1.v4(),
|
|
144
|
-
processingMode: mapi_1.TransactionProcessingMode.Device
|
|
183
|
+
processingMode: mapi_1.TransactionProcessingMode.Device,
|
|
184
|
+
services: services
|
|
145
185
|
// processingMode: TransactionProcessingMode.DeviceRouted
|
|
146
186
|
};
|
|
147
187
|
utils_1.submitInvoice(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
|
|
@@ -273,7 +313,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
273
313
|
});
|
|
274
314
|
setChosenCustomerApiKey(props.customers[0].apiKey);
|
|
275
315
|
}
|
|
276
|
-
var
|
|
316
|
+
var _r = react_1.useState(undefined), billingLinesMetadata = _r[0], setBillingLinesMetadata = _r[1];
|
|
277
317
|
var getBillingLines = function (changedValues, allValues) {
|
|
278
318
|
var invoiceLines = allValues.invoice.invoiceLines;
|
|
279
319
|
if (invoiceLines) {
|
|
@@ -299,7 +339,14 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
299
339
|
}
|
|
300
340
|
};
|
|
301
341
|
return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
|
|
302
|
-
react_1.default.createElement(antd_1.Form, __assign({
|
|
342
|
+
react_1.default.createElement(antd_1.Form, __assign({ onFieldsChange: function () {
|
|
343
|
+
if (captchaVerified && recaptchaRef) {
|
|
344
|
+
if (recaptchaRef.current) {
|
|
345
|
+
setCaptchaVerified(false);
|
|
346
|
+
recaptchaRef.current.reset();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}, scrollToFirstError: true, onValuesChange: function (changedValues, allValues) { return getBillingLines(changedValues, allValues); } }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, initialValues: {
|
|
303
350
|
invoice: {
|
|
304
351
|
supplier: {
|
|
305
352
|
address: {
|
|
@@ -350,10 +397,13 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
350
397
|
react_1.default.createElement(components_1.Attachments, { formInstance: form, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language, file1: file1, setFile1: setFile1, attachmentFieldValidation1: attachmentFieldValidation1, setAttachmentFieldValidation1: setAttachmentFieldValidation1, file2: file2, setFile2: setFile2, attachmentFieldValidation2: attachmentFieldValidation2, setAttachmentFieldValidation2: setAttachmentFieldValidation2, file3: file3, setFile3: setFile3, attachmentFieldValidation3: attachmentFieldValidation3, setAttachmentFieldValidation3: setAttachmentFieldValidation3 })),
|
|
351
398
|
react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
|
|
352
399
|
react_1.default.createElement(antd_1.Col, null,
|
|
353
|
-
react_1.default.createElement(
|
|
354
|
-
|
|
355
|
-
}, hl: props.language }))),
|
|
400
|
+
react_1.default.createElement(reaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", ref: recaptchaRef, onVerify: function (response) {
|
|
401
|
+
setCaptchaVerified(true);
|
|
402
|
+
}, hl: props.language, onExpire: function () { return setCaptchaVerified(false); }, onError: function () { return setCaptchaVerified(false); } }))),
|
|
356
403
|
react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
|
|
404
|
+
react_1.default.createElement(antd_1.Col, null,
|
|
405
|
+
react_1.default.createElement(antd_1.Tooltip, { title: sendCopyDisabled ? intl.formatMessage(translationMessages.createInvoice_SendCopyTooltipDisabled) : intl.formatMessage(translationMessages.createInvoice_SendCopyTooltip) },
|
|
406
|
+
react_1.default.createElement(antd_1.Checkbox, { disabled: sendCopyDisabled, checked: sendCopy, onChange: function (e) { return setSendCopy(e.target.checked); } }, intl.formatMessage(translationMessages.createInvoice_SendCopy)))),
|
|
357
407
|
react_1.default.createElement(antd_1.Col, null,
|
|
358
408
|
react_1.default.createElement(antd_1.Button, { type: "primary", htmlType: "submit", size: "large", disabled: isSubmitDisabled }, intl.formatMessage(translationMessages.createInvoice_Submit))))))));
|
|
359
409
|
};
|
|
@@ -133,14 +133,17 @@
|
|
|
133
133
|
"unitOfMeasure_labels_SquareMetre": "Fermetri",
|
|
134
134
|
"unitOfMeasure_labels_CubicMetre": "Rúmmetri",
|
|
135
135
|
"unitOfMeasure_labels_Tonne": "Tonn",
|
|
136
|
-
"unitOfMeasure_labels_KiloWattHour": "
|
|
137
|
-
"unitOfMeasure_labels_One": "
|
|
136
|
+
"unitOfMeasure_labels_KiloWattHour": "Kílóvattstund",
|
|
137
|
+
"unitOfMeasure_labels_One": "Eining",
|
|
138
138
|
"createInvoice_addDocumentLineMsg": "Bætið við a.m.k einnig línu í skrá",
|
|
139
139
|
"createInvoice_selectCustomerMsg": "Viðskiptavinur verður að vera valinn",
|
|
140
140
|
"createInvoice_successfullySubmittedInvoiceMsg": "Sending reiknings tókst",
|
|
141
141
|
"createInvoice_successfullyUploadedAttachmentMsg": "Það tókst að hlaða upp viðhenginu {attachment}",
|
|
142
142
|
"createInvoice_ErrorUploadedAttachmentMsg": "Villa við að hlaða upp viðhenginu {attachment}",
|
|
143
143
|
"createInvoice_Submit": "Senda",
|
|
144
|
+
"createInvoice_SendCopy": "Senda afrit",
|
|
145
|
+
"createInvoice_SendCopyTooltip": "Sendir þér afrit af reikningnum sem PDF",
|
|
146
|
+
"createInvoice_SendCopyTooltipDisabled": "Netfang þarf að fyllast út til þess að hægt sé að senda þér afrit",
|
|
144
147
|
"billingLines_labels_addButton": "Bæta við línu",
|
|
145
148
|
"rulesMessages_name_required": "Vinsamlega sláið inn heiti hluts",
|
|
146
149
|
"rulesMessages_unitOfMeasure_required": "Vinsamlega veljið mælieiningu",
|
|
@@ -143,6 +143,9 @@ declare const _default: {
|
|
|
143
143
|
"createInvoice_successfullyUploadedAttachmentMsg": string;
|
|
144
144
|
"createInvoice_ErrorUploadedAttachmentMsg": string;
|
|
145
145
|
"createInvoice_Submit": string;
|
|
146
|
+
"createInvoice_SendCopy": string;
|
|
147
|
+
"createInvoice_SendCopyTooltip": string;
|
|
148
|
+
"createInvoice_SendCopyTooltipDisabled": string;
|
|
146
149
|
"billingLines_labels_addButton": string;
|
|
147
150
|
"rulesMessages_name_required": string;
|
|
148
151
|
"rulesMessages_unitOfMeasure_required": string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unimaze/billing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@ant-design/compatible": "latest",
|
|
12
|
-
"@types/react-google-recaptcha": "^2.1.0",
|
|
13
12
|
"@unimaze/api-clients": "1.2.1",
|
|
14
13
|
"antd-mask-input": "^0.1.13",
|
|
15
|
-
"react-google-recaptcha": "^2.1.0",
|
|
16
14
|
"react-hot-loader": "^4.12.20",
|
|
17
15
|
"react-intl": "2.9.0",
|
|
16
|
+
"reaptcha": "^1.7.2",
|
|
18
17
|
"uuid": "latest"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|