@unimaze/billing 0.12.14 → 0.12.16

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.
@@ -7,18 +7,12 @@ interface Props extends InjectedIntlProps {
7
7
  fieldName: "file1" | "file2" | "file3";
8
8
  formInstance: FormInstance;
9
9
  uploadSizeLimit: number;
10
- }
11
- interface States {
12
10
  file: UploadFile[];
13
- attachmentFiledValid: ValidateStatus;
14
- }
15
- declare class Attachment extends React.Component<Props, States> {
16
- constructor(props: Props);
17
- handleRemoveFile: () => void;
18
- normFile: (e: any) => any;
19
- render(): JSX.Element;
11
+ setFile: (file: UploadFile[]) => void;
12
+ attachmentFieldValidation: ValidateStatus;
13
+ setAttachmentFieldValidation: (attachmentFieldValidation: ValidateStatus) => void;
20
14
  }
21
- declare const _default: React.ComponentClass<Pick<Props & React.RefAttributes<Attachment>, "key" | "ref" | "fieldName" | "formInstance" | "uploadSizeLimit">, any> & {
22
- WrappedComponent: React.ComponentType<Props & React.RefAttributes<Attachment> & InjectedIntlProps>;
15
+ declare const _default: React.ComponentClass<Pick<Props, "file" | "fieldName" | "formInstance" | "uploadSizeLimit" | "setFile" | "attachmentFieldValidation" | "setAttachmentFieldValidation">, any> & {
16
+ WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
23
17
  };
24
18
  export default _default;
@@ -1,17 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
2
  var __assign = (this && this.__assign) || function () {
16
3
  __assign = Object.assign || function(t) {
17
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -79,89 +66,83 @@ var translationMessages = react_intl_1.defineMessages({
79
66
  defaultMessage: "File failed to upload",
80
67
  },
81
68
  });
82
- var Attachment = /** @class */ (function (_super) {
83
- __extends(Attachment, _super);
84
- function Attachment(props) {
85
- var _this = _super.call(this, props) || this;
86
- _this.handleRemoveFile = function () {
87
- _this.setState(function (prevStates) { return (__assign({}, prevStates, { file: [], attachmentFiledValid: "" })); });
88
- };
89
- _this.normFile = function (e) {
90
- if (Array.isArray(e)) {
91
- return e;
92
- }
93
- _this.setState(function (prevStates) { return (__assign({}, prevStates, { file: e && e.fileList })); });
94
- return e && e.fileList;
95
- };
96
- _this.state = {
97
- file: [],
98
- attachmentFiledValid: "",
99
- };
100
- return _this;
101
- }
102
- Attachment.prototype.render = function () {
103
- var _this = this;
104
- var fieldName = this.props.fieldName;
105
- var returnOtherFieldNames = function (fn) {
106
- switch (fn) {
107
- case "file1":
108
- return ["file2", "file3"];
109
- case "file2":
110
- return ["file1", "file3"];
111
- case "file3":
112
- return ["file1", "file2"];
113
- }
114
- };
115
- var attachmentLabelsDescriptionErrorMsg = this.props.intl.formatMessage(translationMessages.attachment_labels_descriptionErrorMsg);
116
- var verifyTheAttachment = function (info, uploadSizeLimit, formInstance) {
117
- _this.setState(function (prevState) { return (__assign({}, prevState, { attachmentFiledValid: "validating" })); });
118
- var ifFileIsValid = FileUploadUtility_1.reportIfFileIsValid(info.file, uploadSizeLimit, {
119
- uploadErrorToLarge: _this.props.intl.formatMessage(translationMessages.attachment_error_fileTooLarge, { uploadSizeLimit: uploadSizeLimit / 1024 }),
120
- uploadErrorWrongType: _this.props.intl.formatMessage(translationMessages.attachment_error_fileWrongType),
121
- uploadFailed: _this.props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
122
- });
123
- if (!ifFileIsValid) {
124
- formInstance.resetFields(["attachments", "" + _this.props.fieldName, "file"]);
125
- _this.setState(function (prevState) { return (__assign({}, prevState, { attachmentFiledValid: "error", file: [] })); });
126
- }
127
- else {
128
- _this.setState(function (prevState) { return (__assign({}, prevState, { attachmentFiledValid: "success", file: [info.file] })); });
129
- }
130
- };
131
- return (React.createElement(React.Fragment, null,
132
- React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemVerticalLayout, { label: this.props.intl.formatMessage(translationMessages.attachment_labels_File), name: ["attachments", "" + fieldName, "file"], valuePropName: "fileList", getValueFromEvent: this.normFile, validateStatus: this.state.attachmentFiledValid }),
133
- React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + fieldName, multiple: false, onRemove: this.handleRemoveFile, onChange: function (info) { verifyTheAttachment(info, _this.props.uploadSizeLimit, _this.props.formInstance); }, beforeUpload: function (file) { return false; }, fileList: this.state.file },
134
- React.createElement("p", null, this.props.intl.formatMessage(translationMessages.attachment_labels_uploadFileMsg)))),
135
- React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemVerticalLayout, { label: this.props.intl.formatMessage(translationMessages.attachment_labels_Description), name: ["attachments", "" + fieldName, "description"], rules: [
136
- {
137
- required: this.state.file.length > 0,
138
- message: this.props.intl.formatMessage(translationMessages.attachment_labels_Description_requiredMessage),
139
- },
140
- function (_a) {
141
- var getFieldValue = _a.getFieldValue;
142
- return ({
143
- validator: function (rule, value) {
144
- if (!value || getFieldValue(["attachments", returnOtherFieldNames(fieldName)[0], "description"]) !== value) {
145
- return Promise.resolve();
146
- }
147
- return Promise.reject(attachmentLabelsDescriptionErrorMsg);
69
+ var Attachment = function (props) {
70
+ var fieldName = props.fieldName;
71
+ var handleRemoveFile = function () {
72
+ props.setFile([]);
73
+ props.setAttachmentFieldValidation("");
74
+ };
75
+ var normFile = function (e) {
76
+ if (Array.isArray(e)) {
77
+ return e;
78
+ }
79
+ props.setFile(e && e.fileList);
80
+ return e && e.fileList;
81
+ };
82
+ var returnOtherFieldNames = function (fn) {
83
+ switch (fn) {
84
+ case "file1":
85
+ return ["file2", "file3"];
86
+ case "file2":
87
+ return ["file1", "file3"];
88
+ case "file3":
89
+ return ["file1", "file2"];
90
+ }
91
+ };
92
+ var attachmentLabelsDescriptionErrorMsg = props.intl.formatMessage(translationMessages.attachment_labels_descriptionErrorMsg);
93
+ var verifyTheAttachment = function (info, uploadSizeLimit, formInstance) {
94
+ if (info.file.status === "removed")
95
+ return;
96
+ props.setAttachmentFieldValidation("validating");
97
+ var ifFileIsValid = FileUploadUtility_1.reportIfFileIsValid(info.file, uploadSizeLimit, {
98
+ uploadErrorToLarge: props.intl.formatMessage(translationMessages.attachment_error_fileTooLarge, { uploadSizeLimit: uploadSizeLimit / 1024 }),
99
+ uploadErrorWrongType: props.intl.formatMessage(translationMessages.attachment_error_fileWrongType),
100
+ uploadFailed: props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
101
+ });
102
+ if (!ifFileIsValid) {
103
+ formInstance.resetFields(["attachments", "" + props.fieldName, "file"]);
104
+ props.setAttachmentFieldValidation("error");
105
+ props.setFile([]);
106
+ }
107
+ else {
108
+ props.setAttachmentFieldValidation("success");
109
+ props.setFile([info.file]);
110
+ }
111
+ };
112
+ return (React.createElement(React.Fragment, null,
113
+ React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemVerticalLayout, { label: props.intl.formatMessage(translationMessages.attachment_labels_File), name: ["attachments", "" + fieldName, "file"], valuePropName: "fileList", getValueFromEvent: normFile, validateStatus: props.attachmentFieldValidation }),
114
+ React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + fieldName, multiple: false, onRemove: handleRemoveFile, onChange: function (info) {
115
+ verifyTheAttachment(info, props.uploadSizeLimit, props.formInstance);
116
+ }, beforeUpload: function (file) { return false; }, fileList: props.file },
117
+ React.createElement("p", null, props.intl.formatMessage(translationMessages.attachment_labels_uploadFileMsg)))),
118
+ React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemVerticalLayout, { label: props.intl.formatMessage(translationMessages.attachment_labels_Description), name: ["attachments", "" + fieldName, "description"], rules: [
119
+ {
120
+ required: props.file.length > 0,
121
+ message: props.intl.formatMessage(translationMessages.attachment_labels_Description_requiredMessage),
122
+ },
123
+ function (_a) {
124
+ var getFieldValue = _a.getFieldValue;
125
+ return ({
126
+ validator: function (rule, value) {
127
+ if (!value || getFieldValue(["attachments", returnOtherFieldNames(fieldName)[0], "description"]) !== value) {
128
+ return Promise.resolve();
148
129
  }
149
- });
150
- },
151
- function (_a) {
152
- var getFieldValue = _a.getFieldValue;
153
- return ({
154
- validator: function (rule, value) {
155
- if (!value || getFieldValue(["attachments", returnOtherFieldNames(fieldName)[1], "description"]) !== value) {
156
- return Promise.resolve();
157
- }
158
- return Promise.reject(attachmentLabelsDescriptionErrorMsg);
130
+ return Promise.reject(attachmentLabelsDescriptionErrorMsg);
131
+ }
132
+ });
133
+ },
134
+ function (_a) {
135
+ var getFieldValue = _a.getFieldValue;
136
+ return ({
137
+ validator: function (rule, value) {
138
+ if (!value || getFieldValue(["attachments", returnOtherFieldNames(fieldName)[1], "description"]) !== value) {
139
+ return Promise.resolve();
159
140
  }
160
- });
161
- },
162
- ] }),
163
- React.createElement(antd_1.Input, null))));
164
- };
165
- return Attachment;
166
- }(React.Component));
141
+ return Promise.reject(attachmentLabelsDescriptionErrorMsg);
142
+ }
143
+ });
144
+ },
145
+ ] }),
146
+ React.createElement(antd_1.Input, null))));
147
+ };
167
148
  exports.default = react_intl_1.injectIntl(React.memo(Attachment));
@@ -2,6 +2,8 @@ import * as React from 'react';
2
2
  import { InjectedIntlProps } from "react-intl";
3
3
  import { FormInstance } from "antd/es/form";
4
4
  import { LanguageProp } from "../../types/CommonProps";
5
+ import { UploadFile } from "antd/es/upload/interface";
6
+ import { ValidateStatus } from "antd/lib/form/FormItem";
5
7
  interface Props extends InjectedIntlProps {
6
8
  formInstance: FormInstance;
7
9
  uploadSizeLimit: number;
@@ -10,8 +12,20 @@ interface Props extends InjectedIntlProps {
10
12
  en: string;
11
13
  };
12
14
  languageString: LanguageProp;
15
+ file1: UploadFile[];
16
+ setFile1: (file: UploadFile[]) => void;
17
+ attachmentFieldValidation1: ValidateStatus;
18
+ setAttachmentFieldValidation1: (attachmentFieldValidation: ValidateStatus) => void;
19
+ file2: UploadFile[];
20
+ setFile2: (file: UploadFile[]) => void;
21
+ attachmentFieldValidation2: ValidateStatus;
22
+ setAttachmentFieldValidation2: (attachmentFieldValidation: ValidateStatus) => void;
23
+ file3: UploadFile[];
24
+ setFile3: (file: UploadFile[]) => void;
25
+ attachmentFieldValidation3: ValidateStatus;
26
+ setAttachmentFieldValidation3: (attachmentFieldValidation: ValidateStatus) => void;
13
27
  }
14
- declare const AttachmentGroupIntl: React.ComponentClass<Pick<Props, "formInstance" | "uploadSizeLimit" | "attachmentTooltipText" | "languageString">, any> & {
28
+ declare const AttachmentGroupIntl: React.ComponentClass<Pick<Props, "file1" | "file2" | "file3" | "formInstance" | "uploadSizeLimit" | "attachmentTooltipText" | "languageString" | "setFile1" | "attachmentFieldValidation1" | "setAttachmentFieldValidation1" | "setFile2" | "attachmentFieldValidation2" | "setAttachmentFieldValidation2" | "setFile3" | "attachmentFieldValidation3" | "setAttachmentFieldValidation3">, any> & {
15
29
  WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
16
30
  };
17
31
  export default AttachmentGroupIntl;
@@ -38,11 +38,11 @@ var AttachmentsGroup = function (props) {
38
38
  return (React.createElement(components_1.ComponentContainer, { title: attachmentLabelNode },
39
39
  React.createElement(antd_1.Row, { gutter: [16, 16] },
40
40
  React.createElement(antd_1.Col, { span: 8 },
41
- React.createElement(Attachment_1.default, { key: "attachment1", fieldName: "file1", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit })),
41
+ React.createElement(Attachment_1.default, { key: "attachment1", fieldName: "file1", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit, file: props.file1, setFile: props.setFile1, attachmentFieldValidation: props.attachmentFieldValidation1, setAttachmentFieldValidation: props.setAttachmentFieldValidation1 })),
42
42
  React.createElement(antd_1.Col, { span: 8 },
43
- React.createElement(Attachment_1.default, { key: "attachment2", fieldName: "file2", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit })),
43
+ React.createElement(Attachment_1.default, { key: "attachment2", fieldName: "file2", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit, file: props.file2, setFile: props.setFile2, attachmentFieldValidation: props.attachmentFieldValidation2, setAttachmentFieldValidation: props.setAttachmentFieldValidation2 })),
44
44
  React.createElement(antd_1.Col, { span: 8 },
45
- React.createElement(Attachment_1.default, { key: "attachment3", fieldName: "file3", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit })))));
45
+ React.createElement(Attachment_1.default, { key: "attachment3", fieldName: "file3", formInstance: props.formInstance, uploadSizeLimit: props.uploadSizeLimit, file: props.file3, setFile: props.setFile3, attachmentFieldValidation: props.attachmentFieldValidation3, setAttachmentFieldValidation: props.setAttachmentFieldValidation3 })))));
46
46
  };
47
47
  var AttachmentGroupIntl = react_intl_1.injectIntl(AttachmentsGroup);
48
48
  exports.default = AttachmentGroupIntl;
@@ -66,6 +66,10 @@ var translationMessages = react_intl_1.defineMessages({
66
66
  id: "billingLines_discount",
67
67
  defaultMessage: "Discount"
68
68
  },
69
+ billingLines_discount_helpText: {
70
+ id: "billingLines_discount_helpText",
71
+ defaultMessage: "Discount can be represented as an amount or a percentage indicated with a percentage sign (%)"
72
+ },
69
73
  billingLines_lineAmount: {
70
74
  id: "billingLines_lineAmount",
71
75
  defaultMessage: "Amount"
@@ -141,7 +145,7 @@ var BillingLines = function (props) {
141
145
  return (react_1.default.createElement(antd_1.Select.Option, { disabled: getTaxCategoryDisabled(mapi_1.TaxCategoryTypeEnum[taxCategoryType], props.outsideVatScope), value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, props.intl.formatMessage(editable_cell_1.commonTranslationMessages["taxCategoryType_labels_" + taxCategoryType]) + " (" + taxPercentage + "%)"));
142
146
  })))),
143
147
  react_1.default.createElement(antd_1.Col, { span: 2 },
144
- react_1.default.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], defaultIsRequired: false, fieldName: [field.name, "discountValue"], defaultLabel: props.intl.formatMessage(translationMessages.billingLines_discount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index }, BillingLineUtility_1.getCorrectInputNode("discountValue", props.intl))),
148
+ react_1.default.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], defaultIsRequired: false, fieldName: [field.name, "discountValue"], defaultLabel: props.intl.formatMessage(translationMessages.billingLines_discount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index, defaultLabelTooltip: props.intl.formatMessage(translationMessages.billingLines_discount_helpText) }, BillingLineUtility_1.getCorrectInputNode("discountValue", props.intl))),
145
149
  react_1.default.createElement(antd_1.Col, { span: 2 },
146
150
  react_1.default.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.taxableAmount"], defaultIsRequired: false, fieldName: [field.name, "taxableAmount"], defaultLabel: props.intl.formatMessage(translationMessages.billingLines_lineAmount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index }, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(getTaxableAmount(), props.intl))),
147
151
  react_1.default.createElement(antd_1.Col, { span: 3 },
@@ -219,12 +219,14 @@ var Supplier = function (props) {
219
219
  React.createElement(antd_1.Checkbox, { onChange: function (e) { return props.setOutsideVatScope(e.target.checked); } })),
220
220
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.address.streetNameAndNumber"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_address_streetNameAndNumber), defaultIsRequired: true, fieldName: ["invoice", "supplier", "address", "streetNameAndNumber"] },
221
221
  React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
222
- React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.address.postalZone"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_address_zip_postalCode), defaultIsRequired: true, fieldName: ["invoice", "supplier", "address", "postalZone"] },
222
+ React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.address.postalZone"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_address_zip_postalCode), defaultIsRequired: false, fieldName: ["invoice", "supplier", "address", "postalZone"] },
223
223
  React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
224
224
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.address.city"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_address_city), defaultIsRequired: false, fieldName: ["invoice", "supplier", "address", "city"] },
225
225
  React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
226
226
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.address.countryCode"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_address_countryCode), defaultIsRequired: true, fieldName: ["invoice", "supplier", "address", "countryCode"] },
227
227
  React.createElement(antd_1.Input, { disabled: true })),
228
+ 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"] },
229
+ React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
228
230
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.contact.electronicMail"], defaultLabel: electronicMailLabelNode, defaultIsRequired: false, fieldName: ["invoice", "supplier", "contact", "electronicMail"], additionalRules: [
229
231
  {
230
232
  type: 'email',
@@ -232,8 +234,6 @@ var Supplier = function (props) {
232
234
  }
233
235
  ] },
234
236
  React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
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"] },
236
- React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
237
237
  getSupplierTelephoneFieldDefinitions(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
238
  React.createElement(antd_1.Input, null)))
239
239
  : null));
@@ -66,6 +66,7 @@ var translationMessages = react_intl_1.defineMessages({
66
66
  * @component
67
67
  */
68
68
  var CreateInvoiceConstructor = function (props) {
69
+ var recaptchaRef = react_1.default.useRef(null);
69
70
  var intl = props.intl;
70
71
  var form = antd_1.Form.useForm()[0];
71
72
  var _a = react_1.useState(false), submitting = _a[0], setSubmitting = _a[1];
@@ -75,6 +76,14 @@ var CreateInvoiceConstructor = function (props) {
75
76
  var _e = react_1.default.useState(""), referenceIdentifierValidateStatus = _e[0], setReferenceIdentifierValidateStatus = _e[1];
76
77
  // const [billingLinesEditableIndex, setBillingLinesEditableIndex] = useState<number>(1)
77
78
  var _f = react_1.useState(false), outsideVatScope = _f[0], setOutsideVatScope = _f[1];
79
+ // attachments
80
+ // TODO: remove the states, set the values to the form in attachment components
81
+ var _g = react_1.useState([]), file1 = _g[0], setFile1 = _g[1];
82
+ var _h = react_1.useState(""), attachmentFieldValidation1 = _h[0], setAttachmentFieldValidation1 = _h[1];
83
+ var _j = react_1.useState([]), file2 = _j[0], setFile2 = _j[1];
84
+ var _k = react_1.useState(""), attachmentFieldValidation2 = _k[0], setAttachmentFieldValidation2 = _k[1];
85
+ var _l = react_1.useState([]), file3 = _l[0], setFile3 = _l[1];
86
+ var _m = react_1.useState(""), attachmentFieldValidation3 = _m[0], setAttachmentFieldValidation3 = _m[1];
78
87
  react_1.useEffect(function () {
79
88
  form.resetFields([
80
89
  ["invoice", "supplier", "vatNumber"],
@@ -98,76 +107,16 @@ var CreateInvoiceConstructor = function (props) {
98
107
  }
99
108
  });
100
109
  }, [outsideVatScope]);
101
- // const initialBillingLineData: BillingLineMetadataOverride = {
102
- // key: billingLinesEditableIndex,
103
- // itemNo: props.intl.formatMessage(billingLineTranslationMessages.billingLines_placeholders_itemNo), // "Item No.",// (dataSource.length > 0 ? Number(dataSource[dataSource.length-1].itemNo) + 1 : 1).toString(),
104
- // quantity: 0,
105
- // taxAmount: 0,
106
- // name: props.intl.formatMessage(billingLineTranslationMessages.billingLines_placeholders_newItem), // `New Item`,
107
- // unitOfMeasure: {
108
- // value: Units.Piece,
109
- // label: props.intl.formatMessage(commonTranslationMessages.unitOfMeasure_labels_Piece)
110
- // },
111
- // unitPriceAmount: 0,
112
- // taxCategoryType: {
113
- // value: TaxCategoryTypeEnum.OutsideTaxScope,
114
- // label: `${props.intl.formatMessage(commonTranslationMessages.taxCategoryType_labels_OutsideTaxScope)} (0%)`
115
- // },
116
- // discountValue: "0",
117
- // taxableAmount: 0,
118
- // taxPercentage: 0
119
- // };
120
- // const [billingLinesDataSource, setBillingLinesDataSource] = useState<BillingLineMetadataOverride[]>([{
121
- // ...initialBillingLineData,
122
- // key: 0,
123
- // }])
124
- // BILLING LINES
125
- // const handleBillingLinesDelete = (index: number) => {
126
- // const newDataSource = [...billingLinesDataSource];
127
- // const indexToDelete = newDataSource.findIndex(billingLine => billingLine.key === index)
128
- // newDataSource.splice(indexToDelete, 1);
129
- // setBillingLinesDataSource(newDataSource);
130
- // };
131
- //
132
- // const handleBillingLinesAdd = (billingLineToAdd: BillingLineMetadataOverride) => {
133
- // setBillingLinesDataSource([...billingLinesDataSource, billingLineToAdd])
134
- // setBillingLinesEditableIndex(billingLinesEditableIndex + 1)
135
- // };
136
- //
137
- //
138
- // const handleBillingLinesSave = (row: BillingLineMetadataOverride, formInstance: FormInstance) => {
139
- // const newData = [...billingLinesDataSource];
140
- // const index = newData.findIndex((i) => {
141
- // return row.key === i.key;
142
- // });
143
- //
144
- // const item = newData[index];
145
- // newData.splice(index, 1, {
146
- // ...item,
147
- // ...row,
148
- // });
149
- //
150
- // const billingLineMetadata = newData.map<BillingLineMetadata>(current => {
151
- // return {
152
- // ...current,
153
- // unitOfMeasure: {
154
- // unit: Units[current.unitOfMeasure.value],
155
- // },
156
- // taxCategoryType: TaxCategoryTypeEnum[current.taxCategoryType.value]
157
- // }
158
- // });
159
- //
160
- // setBillingLinesDataSource(newData)
161
- //
162
- // handleSetBillingLineMetadata(formInstance, billingLineMetadata);
163
- // };
164
- // END BILLING LINES
165
- // const handleSetBillingLineMetadata = (formInstance: FormInstance, billingLineMetadata: BillingLineMetadata[]) => {
166
- // formInstance.setFieldsValue({
167
- // "billingLinesMetadata": billingLineMetadata
168
- // })
169
- // };
110
+ var resetAttachments = function () {
111
+ setFile1([]);
112
+ setAttachmentFieldValidation1("");
113
+ setFile2([]);
114
+ setAttachmentFieldValidation2("");
115
+ setFile3([]);
116
+ setAttachmentFieldValidation3("");
117
+ };
170
118
  var handleSubmit = function (values) {
119
+ // console.log("values at the start of submit", values);
171
120
  setSubmitting(true);
172
121
  if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
173
122
  form.scrollToField(["invoice", "referenceIdentifiers", 0, "value"]);
@@ -245,7 +194,31 @@ var CreateInvoiceConstructor = function (props) {
245
194
  _loop_1();
246
195
  }
247
196
  setSubmitting(false);
197
+ // console.log("values after successful submit", values);
248
198
  form.resetFields();
199
+ form.setFields([
200
+ {
201
+ name: ["invoice", "invoiceLines"],
202
+ value: [{}]
203
+ },
204
+ {
205
+ name: ["invoice", "supplier"],
206
+ value: values.invoice.supplier,
207
+ },
208
+ {
209
+ name: ["outsideVatScope"],
210
+ value: !values.invoice.supplier.vatNumber
211
+ },
212
+ {
213
+ name: ["attachments"],
214
+ value: {
215
+ file1: { file: undefined, description: undefined },
216
+ file2: { file: undefined, description: undefined },
217
+ file3: { file: undefined, description: undefined },
218
+ }
219
+ }
220
+ ]);
221
+ resetAttachments();
249
222
  // Clear the billing line dataSource
250
223
  setChosenCustomer(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0]));
251
224
  setChosenCustomerApiKey(props.customers[0].apiKey);
@@ -280,6 +253,12 @@ var CreateInvoiceConstructor = function (props) {
280
253
  // tslint:disable-next-line:no-console
281
254
  console.log(error.config);
282
255
  });
256
+ if (recaptchaRef) {
257
+ if (recaptchaRef.current) {
258
+ recaptchaRef.current.reset();
259
+ }
260
+ }
261
+ setIsSubmitDisabled(true);
283
262
  };
284
263
  react_1.useEffect(function () {
285
264
  getReceiverRequirements();
@@ -313,7 +292,7 @@ var CreateInvoiceConstructor = function (props) {
313
292
  });
314
293
  setChosenCustomerApiKey(props.customers[0].apiKey);
315
294
  }
316
- var _g = react_1.useState(undefined), billingLinesMetadata = _g[0], setBillingLinesMetadata = _g[1];
295
+ var _o = react_1.useState(undefined), billingLinesMetadata = _o[0], setBillingLinesMetadata = _o[1];
317
296
  var getBillingLines = function (changedValues, allValues) {
318
297
  var invoiceLines = allValues.invoice.invoiceLines;
319
298
  if (invoiceLines) {
@@ -355,7 +334,12 @@ var CreateInvoiceConstructor = function (props) {
355
334
  referenceIdentifiers: [
356
335
  {}
357
336
  ],
358
- invoiceLines: [{}]
337
+ invoiceLines: [{}],
338
+ attachments: {
339
+ file1: { file: undefined, description: undefined },
340
+ file2: { file: undefined, description: undefined },
341
+ file3: { file: undefined, description: undefined },
342
+ }
359
343
  },
360
344
  } }),
361
345
  react_1.default.createElement(antd_1.Row, { gutter: [16, 16] },
@@ -382,10 +366,10 @@ var CreateInvoiceConstructor = function (props) {
382
366
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
383
367
  react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form })),
384
368
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 16 } },
385
- react_1.default.createElement(components_1.Attachments, { formInstance: form, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language })),
369
+ 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 })),
386
370
  react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
387
371
  react_1.default.createElement(antd_1.Col, null,
388
- react_1.default.createElement(react_google_recaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", onChange: function (token) {
372
+ react_1.default.createElement(react_google_recaptcha_1.default, { ref: recaptchaRef, sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", onChange: function (token) {
389
373
  setIsSubmitDisabled(!token);
390
374
  }, hl: props.language }))),
391
375
  react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
@@ -48,6 +48,7 @@
48
48
  "billingLines_taxCategoryType_title": "Ekki er hægt að leggja virðisauka á vöru nema gefa upp VSK númer",
49
49
  "billingLines_taxCategoryPercentage": "Skattprósenta",
50
50
  "billingLines_discount": "Afsláttur",
51
+ "billingLines_discount_helpText": "Afslátt má setja fram sem upphæð eða sem hlutfall með því að bæta við prósentutákni (%)",
51
52
  "billingLines_lineAmount": "Upphæð",
52
53
  "billingLines_taxAmount": "Upphæð með skatti",
53
54
  "billingLines_button_addRow": "Bæta við röð",
@@ -50,6 +50,7 @@ declare const _default: {
50
50
  "billingLines_taxCategoryType_title": string;
51
51
  "billingLines_taxCategoryPercentage": string;
52
52
  "billingLines_discount": string;
53
+ "billingLines_discount_helpText": string;
53
54
  "billingLines_lineAmount": string;
54
55
  "billingLines_taxAmount": string;
55
56
  "billingLines_button_addRow": string;
@@ -150,7 +150,7 @@ var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalcul
150
150
  if (resp.invoice && resp.invoice.delivery && resp.invoice.delivery === {}) {
151
151
  delete resp.invoice.delivery;
152
152
  }
153
- if (resp.invoice && resp.invoice.orderReference) {
153
+ if (resp.invoice && !resp.invoice.orderReference) {
154
154
  delete resp.invoice.orderReference;
155
155
  }
156
156
  return resp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.12.14",
3
+ "version": "0.12.16",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",