@unimaze/billing 0.12.5 → 0.12.6
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/base-information/CostCenter.d.ts +12 -0
- package/lib/common/components/base-information/CostCenter.js +107 -0
- package/lib/common/components/customer/index.js +1 -1
- package/lib/common/components/supplier/index.js +14 -3
- package/lib/create-invoice/index.js +2 -2
- package/lib/translations/locales/is.json +1 -0
- package/lib/translations/locales.d.ts +1 -0
- package/lib/utils/ApiUtility.d.ts +2 -2
- package/lib/utils/ApiUtility.js +14 -3
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InjectedIntlProps } from "react-intl";
|
|
3
|
+
import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
|
|
4
|
+
interface Props extends InjectedIntlProps {
|
|
5
|
+
receiverRequirements: NewReceiverRequirements;
|
|
6
|
+
updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void;
|
|
7
|
+
rapiBaseUrl: string;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.ComponentClass<Pick<Props, "receiverRequirements" | "updateReceiverRequirementsProp" | "rapiBaseUrl">, any> & {
|
|
10
|
+
WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14
|
+
if (mod && mod.__esModule) return mod;
|
|
15
|
+
var result = {};
|
|
16
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
17
|
+
result["default"] = mod;
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
var react_1 = __importStar(require("react"));
|
|
25
|
+
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
26
|
+
var antd_1 = require("antd");
|
|
27
|
+
var form_item_1 = __importDefault(require("../form-item"));
|
|
28
|
+
var react_intl_1 = require("react-intl");
|
|
29
|
+
var axios_1 = __importDefault(require("axios"));
|
|
30
|
+
// import {FormInstance} from "antd/es/form";
|
|
31
|
+
var translationMessages = {
|
|
32
|
+
baseInformation_costCenter: {
|
|
33
|
+
id: "baseInformation_costCenter",
|
|
34
|
+
defaultMessage: "Cost center",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
var getCostCenterFieldDefinitions = function (receiverRequirements) {
|
|
38
|
+
return receiverRequirements && receiverRequirements.fieldDefinitions.find(function (fieldRequirement) { return fieldRequirement.key === "customer.locationIdentifier"; });
|
|
39
|
+
};
|
|
40
|
+
var handleReferenceIdentifierValueSearch = function (searchValue, costCenterFieldDefinition, receiverRequirements, rapiBaseUrl, setLoadingCostCenterValues, updateReceiverRequirementsProp) {
|
|
41
|
+
if (costCenterFieldDefinition.properties.href) {
|
|
42
|
+
var searchUrl = rapiBaseUrl + costCenterFieldDefinition.properties.href.replace("%7BtextFilter%7D", searchValue).replace("%7Boffset%7D", "0").replace("%7Blimit%7D", "15");
|
|
43
|
+
setLoadingCostCenterValues(true);
|
|
44
|
+
axios_1.default.get(searchUrl)
|
|
45
|
+
.then(function (response) {
|
|
46
|
+
setLoadingCostCenterValues(false);
|
|
47
|
+
var updatedFieldDefinitions = receiverRequirements.fieldDefinitions.slice();
|
|
48
|
+
var index = updatedFieldDefinitions.findIndex(function (x) { return x.key === costCenterFieldDefinition.key; });
|
|
49
|
+
var updatedReferenceIdentifier = __assign({}, updatedFieldDefinitions[index], { properties: {
|
|
50
|
+
label: updatedFieldDefinitions[index].properties.label,
|
|
51
|
+
href: updatedFieldDefinitions[index].properties.href,
|
|
52
|
+
cardinality: updatedFieldDefinitions[index].properties.cardinality,
|
|
53
|
+
values: response.data.value
|
|
54
|
+
} });
|
|
55
|
+
updatedFieldDefinitions.splice(index, 1, updatedReferenceIdentifier);
|
|
56
|
+
var newReceiverRequirements = __assign({}, receiverRequirements, { fieldDefinitions: updatedFieldDefinitions });
|
|
57
|
+
updateReceiverRequirementsProp(newReceiverRequirements);
|
|
58
|
+
})
|
|
59
|
+
.catch(function (error) {
|
|
60
|
+
setLoadingCostCenterValues(false);
|
|
61
|
+
// tslint:disable-next-line:no-console
|
|
62
|
+
console.log(error);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var getCostCenterInput = function (receiverRequirements, rapiBaseUrl, setLoadingCostCenterValues, loadingCostCenterValues, updateReceiverRequirementsProp) {
|
|
67
|
+
var costCenterFieldDefinition = getCostCenterFieldDefinitions(receiverRequirements);
|
|
68
|
+
if (costCenterFieldDefinition) {
|
|
69
|
+
if (costCenterFieldDefinition.properties && costCenterFieldDefinition.properties.hasOwnProperty("values") && costCenterFieldDefinition.properties.values) {
|
|
70
|
+
var selectProps = costCenterFieldDefinition.properties.hasOwnProperty("href")
|
|
71
|
+
? {
|
|
72
|
+
showSearch: true,
|
|
73
|
+
filterOption: false,
|
|
74
|
+
onSearch: function (searchValue) {
|
|
75
|
+
handleReferenceIdentifierValueSearch(searchValue, costCenterFieldDefinition, receiverRequirements, rapiBaseUrl, setLoadingCostCenterValues, updateReceiverRequirementsProp);
|
|
76
|
+
},
|
|
77
|
+
onChange: function (searchValue) {
|
|
78
|
+
if (!searchValue) {
|
|
79
|
+
handleReferenceIdentifierValueSearch("", costCenterFieldDefinition, receiverRequirements, rapiBaseUrl, setLoadingCostCenterValues, updateReceiverRequirementsProp);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
loading: loadingCostCenterValues,
|
|
83
|
+
}
|
|
84
|
+
: {};
|
|
85
|
+
return react_1.default.createElement(antd_1.Select, __assign({ dropdownMatchSelectWidth: false, allowClear: true }, selectProps), costCenterFieldDefinition.properties.values.map(function (costCenterFieldValue) {
|
|
86
|
+
return react_1.default.createElement(antd_1.Select.Option, { key: costCenterFieldValue.key, value: costCenterFieldValue.key }, costCenterFieldValue.name);
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return react_1.default.createElement(antd_1.Input, null);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return react_1.default.createElement(antd_1.Input, null);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var CostCenter = function (props) {
|
|
98
|
+
var receiverRequirements = props.receiverRequirements, rapiBaseUrl = props.rapiBaseUrl, updateReceiverRequirementsProp = props.updateReceiverRequirementsProp;
|
|
99
|
+
var _a = react_1.useState(false), loadingCostCenterValues = _a[0], setLoadingCostCenterValues = _a[1];
|
|
100
|
+
if (getCostCenterFieldDefinitions(receiverRequirements)) {
|
|
101
|
+
return (react_1.default.createElement(form_item_1.default, { receiverRequirements: receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"], defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_costCenter), defaultIsRequired: false, fieldName: ["invoice", "customer", "locationIdentifier"] }, getCostCenterInput(receiverRequirements, rapiBaseUrl, setLoadingCostCenterValues, loadingCostCenterValues, updateReceiverRequirementsProp)));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.default = react_intl_1.injectIntl(CostCenter);
|
|
@@ -79,7 +79,7 @@ var Customer = function (props) {
|
|
|
79
79
|
react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, defaultLabel: props.intl.formatMessage(translationMessages.customer_selectTheCustomer), defaultIsRequired: true, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.identifier"], fieldName: ["invoice", "customer", "name"] },
|
|
80
80
|
react_1.default.createElement(antd_1.Select, { onChange: function (value) {
|
|
81
81
|
onCustomerChange(value);
|
|
82
|
-
}, dropdownMatchSelectWidth: false }, props.customers.map(function (customer, index) { return (react_1.default.createElement(antd_1.Select.Option, { key: index, value: index }, customer.name)); }))),
|
|
82
|
+
}, dropdownMatchSelectWidth: false, disabled: props.customers.length === 1 }, props.customers.map(function (customer, index) { return (react_1.default.createElement(antd_1.Select.Option, { key: index, value: index }, customer.name)); }))),
|
|
83
83
|
react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_name), style: { display: "none" } }), chosenCustomer && chosenCustomer.name),
|
|
84
84
|
react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_identifier) }), chosenCustomer && ConversionUtility_1.convertToReadableKennitala(chosenCustomer.identifier)),
|
|
85
85
|
react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_address_streetNameAndNumber) }), chosenCustomer && chosenCustomer.address
|
|
@@ -15,11 +15,12 @@ var react_1 = require("react");
|
|
|
15
15
|
var components_1 = require("../../components");
|
|
16
16
|
var antd_1 = require("antd");
|
|
17
17
|
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
18
|
-
var form_item_1 =
|
|
18
|
+
var form_item_1 = __importDefault(require("../form-item"));
|
|
19
19
|
var react_intl_1 = require("react-intl");
|
|
20
20
|
var icons_1 = require("@ant-design/icons");
|
|
21
21
|
// import {defineMessages} from "react-intl.macro"
|
|
22
22
|
var payment_method_1 = require("../payment-method");
|
|
23
|
+
var form_item_2 = require("../form-item");
|
|
23
24
|
var antd_mask_input_1 = require("antd-mask-input");
|
|
24
25
|
var axios_1 = __importDefault(require("axios"));
|
|
25
26
|
var lodash_1 = require("lodash");
|
|
@@ -73,6 +74,10 @@ var translationMessages = react_intl_1.defineMessages({
|
|
|
73
74
|
id: "supplier_contact_name",
|
|
74
75
|
defaultMessage: "Contact name"
|
|
75
76
|
},
|
|
77
|
+
supplier_contact_phoneNumber: {
|
|
78
|
+
id: "supplier_contact_phoneNumber",
|
|
79
|
+
defaultMessage: "Phone number"
|
|
80
|
+
},
|
|
76
81
|
supplier_notValidEmail: {
|
|
77
82
|
id: "supplier_notValidEmail",
|
|
78
83
|
defaultMessage: "This is not a valid E-Mail"
|
|
@@ -177,6 +182,9 @@ var Supplier = function (props) {
|
|
|
177
182
|
getParticipantInfoWithIdentifier(rapiUrl, rapiApiKey, strippedSearchValue);
|
|
178
183
|
}
|
|
179
184
|
}, 500);
|
|
185
|
+
var getCustomerTelephoneFieldDefinitions = function (receiverRequirements) {
|
|
186
|
+
return receiverRequirements && receiverRequirements.fieldDefinitions.find(function (fieldRequirement) { return fieldRequirement.key === "customer.contact.telephone"; });
|
|
187
|
+
};
|
|
180
188
|
return (React.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.supplier_title) },
|
|
181
189
|
React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.identifier"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_identifier), defaultIsRequired: true, fieldName: ["invoice", "supplier", "identifier"], hasFeedback: isLoadingParticipantInfo, validateStatus: isLoadingParticipantInfo ? "validating" : undefined, rules: [
|
|
182
190
|
{
|
|
@@ -185,7 +193,7 @@ var Supplier = function (props) {
|
|
|
185
193
|
},
|
|
186
194
|
{
|
|
187
195
|
required: true,
|
|
188
|
-
message: props.intl.formatMessage(
|
|
196
|
+
message: props.intl.formatMessage(form_item_2.translationMessages.formItem_required_errorMessage),
|
|
189
197
|
}
|
|
190
198
|
] },
|
|
191
199
|
React.createElement(antd_mask_input_1.MaskedInput, { mask: "111111-1111", onChange: function (value) { return debouncerSearch(props.rapiBaseUrl, props.rapiApiKey, value.target.value); } })),
|
|
@@ -225,7 +233,10 @@ var Supplier = function (props) {
|
|
|
225
233
|
] },
|
|
226
234
|
React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
|
|
227
235
|
React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.contact.name"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_contact_name), defaultIsRequired: false, fieldName: ["invoice", "supplier", "contact", "name"] },
|
|
228
|
-
React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo }))
|
|
236
|
+
React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
|
|
237
|
+
getCustomerTelephoneFieldDefinitions(props.receiverRequirements) ? (React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.contact.telephone"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_contact_phoneNumber), defaultIsRequired: false, fieldName: ["invoice", "supplier", "contact", "telephone"] },
|
|
238
|
+
React.createElement(antd_1.Input, null)))
|
|
239
|
+
: null));
|
|
229
240
|
};
|
|
230
241
|
var SupplierIntl = react_intl_1.injectIntl(Supplier);
|
|
231
242
|
exports.default = SupplierIntl;
|
|
@@ -71,7 +71,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
71
71
|
var _a = react_1.useState(false), submitting = _a[0], setSubmitting = _a[1];
|
|
72
72
|
var _b = react_1.useState(true), isSubmitDisabled = _b[0], setIsSubmitDisabled = _b[1];
|
|
73
73
|
var _c = react_1.useState(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0])), chosenCustomer = _c[0], setChosenCustomer = _c[1];
|
|
74
|
-
var _d = react_1.useState(), chosenCustomerApiKey = _d[0], setChosenCustomerApiKey = _d[1];
|
|
74
|
+
var _d = react_1.useState(props.customers[0].apiKey), chosenCustomerApiKey = _d[0], setChosenCustomerApiKey = _d[1];
|
|
75
75
|
// const [billingLinesEditableIndex, setBillingLinesEditableIndex] = useState<number>(1)
|
|
76
76
|
var _e = react_1.useState(false), outsideVatScope = _e[0], setOutsideVatScope = _e[1];
|
|
77
77
|
react_1.useEffect(function () {
|
|
@@ -242,7 +242,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
242
242
|
form.resetFields();
|
|
243
243
|
// Clear the billing line dataSource
|
|
244
244
|
setChosenCustomer(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0]));
|
|
245
|
-
setChosenCustomerApiKey(
|
|
245
|
+
setChosenCustomerApiKey(props.customers[0].apiKey);
|
|
246
246
|
// setBillingLinesDataSource([{...initialBillingLineData, key: 0}])
|
|
247
247
|
// setBillingLinesEditableIndex(0);
|
|
248
248
|
// TODO: remove this as soon as possible
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"supplier_contact_email": "Netfang",
|
|
87
87
|
"supplier_contact_email_title": "Send verður greiðslutilkynning á þetta netfang",
|
|
88
88
|
"supplier_contact_name": "Nafn tengiliðs",
|
|
89
|
+
"supplier_contact_phoneNumber": "Símanúmer",
|
|
89
90
|
"supplier_notValidEmail": "Þetta er ekki gilt netfang",
|
|
90
91
|
"validationRule_kennitalaPattern": "Kennitala verður að passa við mynstur 111111-1111",
|
|
91
92
|
"customer_title": "Viðskiptavinur",
|
|
@@ -88,6 +88,7 @@ declare const _default: {
|
|
|
88
88
|
"supplier_contact_email": string;
|
|
89
89
|
"supplier_contact_email_title": string;
|
|
90
90
|
"supplier_contact_name": string;
|
|
91
|
+
"supplier_contact_phoneNumber": string;
|
|
91
92
|
"supplier_notValidEmail": string;
|
|
92
93
|
"validationRule_kennitalaPattern": string;
|
|
93
94
|
"customer_title": string;
|
|
@@ -17,7 +17,7 @@ interface AttachDocument {
|
|
|
17
17
|
more: boolean;
|
|
18
18
|
}
|
|
19
19
|
declare const submitDocument: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey?: string | undefined) => AxiosPromise<mapi.MessageOutput>;
|
|
20
|
-
declare const submitDocumentFetch: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey
|
|
21
|
-
declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, apiKey
|
|
20
|
+
declare const submitDocumentFetch: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey: string) => Promise<Response>;
|
|
21
|
+
declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, apiKey: string, callName?: string | undefined, language?: LanguageProp) => AxiosPromise<mapi.MessageOutput>;
|
|
22
22
|
export declare const getCancelToken: (callName: string) => CancelToken;
|
|
23
23
|
export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch };
|
package/lib/utils/ApiUtility.js
CHANGED
|
@@ -59,7 +59,11 @@ var submitDocument = function (data, attachDocument, mapiBaseUrl, apiKey) {
|
|
|
59
59
|
exports.submitDocument = submitDocument;
|
|
60
60
|
var submitDocumentFetch = function (data, attachDocument, mapiBaseUrl, apiKey) {
|
|
61
61
|
var messageId = attachDocument.messageId, name = attachDocument.name, contentType = attachDocument.contentType, more = attachDocument.more;
|
|
62
|
-
var headers =
|
|
62
|
+
var headers = {
|
|
63
|
+
Authorization: "Bearer " + window.btoa(apiKey),
|
|
64
|
+
"Content-Type": "application/octet-stream",
|
|
65
|
+
"X-test": "test",
|
|
66
|
+
};
|
|
63
67
|
var responsePromise = fetch(mapiBaseUrl + "/api/v1/messages/" + messageId + "/documents?Name=" + name + "&ContentType=" + contentType + "&More=" + more, {
|
|
64
68
|
method: "POST",
|
|
65
69
|
headers: headers,
|
|
@@ -75,10 +79,17 @@ var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, apiKey, callName
|
|
|
75
79
|
};
|
|
76
80
|
exports.submitInvoice = submitInvoice;
|
|
77
81
|
var createOptions = function (apiKey, callName, language) {
|
|
78
|
-
return __assign({ headers:
|
|
82
|
+
return __assign({ headers: {
|
|
83
|
+
"Accept-Language": language ? language : "en",
|
|
84
|
+
Authorization: "Bearer " + window.btoa(apiKey)
|
|
85
|
+
} }, (callName && { cancelToken: exports.getCancelToken(callName) }));
|
|
79
86
|
};
|
|
80
87
|
var createOptionsData = function (data, apiKey, callName, language) {
|
|
81
|
-
var options = __assign({}, (callName && { cancelToken: exports.getCancelToken(callName) }), { data: data, headers:
|
|
88
|
+
var options = __assign({}, (callName && { cancelToken: exports.getCancelToken(callName) }), { data: data, headers: {
|
|
89
|
+
"Accept-Language": language ? language : "en",
|
|
90
|
+
Authorization: "Bearer " + window.btoa(apiKey),
|
|
91
|
+
"Content-Type": "application/octet-stream"
|
|
92
|
+
} });
|
|
82
93
|
// tslint:disable-next-line:no-console
|
|
83
94
|
console.log(options);
|
|
84
95
|
return options;
|