@unimaze/billing 0.1.2-rc.10 → 0.1.2-rc.3

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.
Files changed (95) hide show
  1. package/README.md +3 -11
  2. package/lib/common/components/attachments/Attachment.d.ts +2 -8
  3. package/lib/common/components/attachments/Attachment.js +7 -33
  4. package/lib/common/components/attachments/index.d.ts +2 -9
  5. package/lib/common/components/attachments/index.js +6 -15
  6. package/lib/common/components/base-information/index.d.ts +3 -6
  7. package/lib/common/components/base-information/index.js +81 -100
  8. package/lib/common/components/billing-lines/index.d.ts +20 -6
  9. package/lib/common/components/billing-lines/index.js +22 -106
  10. package/lib/common/components/component-container/style/index.d.ts +1 -0
  11. package/lib/common/components/component-container/style/index.js +3 -0
  12. package/lib/common/components/delivery-location/index.d.ts +2 -5
  13. package/lib/common/components/delivery-location/index.js +11 -43
  14. package/lib/common/components/editable-cell/index.js +9 -7
  15. package/lib/common/components/index.d.ts +5 -10
  16. package/lib/common/components/index.js +8 -20
  17. package/lib/common/components/issuer/index.d.ts +7 -0
  18. package/lib/common/components/{customer/hardCoddedCustomer.js → issuer/index.js} +8 -5
  19. package/lib/common/components/payer/index.d.ts +3 -0
  20. package/lib/common/components/payer/index.js +51 -0
  21. package/lib/common/components/payment-method/index.d.ts +3 -6
  22. package/lib/common/components/payment-method/index.js +17 -57
  23. package/lib/common/consts/validationRules.js +7 -0
  24. package/lib/common/enums/index.d.ts +1 -1
  25. package/lib/common/enums/index.js +4 -2
  26. package/lib/common/types/ReceiverRequirements.d.ts +17 -72
  27. package/lib/common/types/ReceiverRequirements.js +14 -350
  28. package/lib/create-credit-note/index.d.ts +2 -1
  29. package/lib/create-credit-note/index.js +11 -5
  30. package/lib/create-invoice/index.d.ts +2 -1
  31. package/lib/create-invoice/index.js +17 -77
  32. package/lib/example/src/index.d.ts +1 -1
  33. package/lib/index.js +0 -5
  34. package/lib/src/common/components/base-information/index.d.ts +3 -6
  35. package/lib/src/common/components/billing-lines/index.d.ts +20 -6
  36. package/lib/src/common/components/delivery-location/index.d.ts +2 -5
  37. package/lib/src/common/components/issuer/index.d.ts +7 -0
  38. package/lib/src/common/components/payer/index.d.ts +3 -0
  39. package/lib/src/common/components/payment-method/index.d.ts +3 -6
  40. package/lib/src/common/types/ReceiverRequirements.d.ts +17 -72
  41. package/lib/src/create-invoice/index.d.ts +2 -1
  42. package/lib/src/utils/ApiUtility.d.ts +1 -8
  43. package/lib/src/utils/ConversionUtility.d.ts +2 -3
  44. package/lib/src/utils/index.d.ts +1 -1
  45. package/lib/style/index.css +1222 -0
  46. package/lib/style/index.d.ts +1 -0
  47. package/lib/style/index.js +3 -0
  48. package/lib/utils/ApiUtility.d.ts +1 -8
  49. package/lib/utils/ApiUtility.js +1 -17
  50. package/lib/utils/ConversionUtility.d.ts +2 -3
  51. package/lib/utils/ConversionUtility.js +62 -116
  52. package/lib/utils/index.d.ts +1 -1
  53. package/lib/utils/index.js +0 -1
  54. package/package.json +7 -12
  55. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +0 -6
  56. package/lib/common/components/base-information/ReferenceIdentifiers.js +0 -40
  57. package/lib/common/components/billing-lines/BillingCalculations.d.ts +0 -11
  58. package/lib/common/components/billing-lines/BillingCalculations.js +0 -61
  59. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +0 -10
  60. package/lib/common/components/billing-lines/BillingTaxSummary.js +0 -51
  61. package/lib/common/components/billing-lines/billingLIneFormData.d.ts +0 -7
  62. package/lib/common/components/billing-lines/billingLIneFormData.js +0 -63
  63. package/lib/common/components/customer/hardCoddedCustomer.d.ts +0 -7
  64. package/lib/common/components/customer/index.d.ts +0 -6
  65. package/lib/common/components/customer/index.js +0 -93
  66. package/lib/common/components/form-item/index.d.ts +0 -21
  67. package/lib/common/components/form-item/index.js +0 -27
  68. package/lib/common/components/locale-intl/index.d.ts +0 -10
  69. package/lib/common/components/locale-intl/index.js +0 -45
  70. package/lib/common/components/supplier/index.d.ts +0 -6
  71. package/lib/common/components/supplier/index.js +0 -93
  72. package/lib/src/common/components/attachments/Attachment.d.ts +0 -21
  73. package/lib/src/common/components/attachments/index.d.ts +0 -10
  74. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +0 -6
  75. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +0 -11
  76. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +0 -10
  77. package/lib/src/common/components/billing-lines/billingLIneFormData.d.ts +0 -7
  78. package/lib/src/common/components/customer/index.d.ts +0 -6
  79. package/lib/src/common/components/form-item/index.d.ts +0 -21
  80. package/lib/src/common/components/index.d.ts +0 -10
  81. package/lib/src/common/components/locale-intl/index.d.ts +0 -10
  82. package/lib/src/common/components/supplier/index.d.ts +0 -6
  83. package/lib/src/translations/locales.d.ts +0 -74
  84. package/lib/src/utils/BillingLineUtility.d.ts +0 -8
  85. package/lib/src/utils/RequirementsUtility.d.ts +0 -5
  86. package/lib/src/utils/billingLineFormData.d.ts +0 -7
  87. package/lib/translations/locales/is.json +0 -70
  88. package/lib/translations/locales.d.ts +0 -74
  89. package/lib/translations/locales.js +0 -10
  90. package/lib/utils/BillingLineUtility.d.ts +0 -8
  91. package/lib/utils/BillingLineUtility.js +0 -66
  92. package/lib/utils/RequirementsUtility.d.ts +0 -5
  93. package/lib/utils/RequirementsUtility.js +0 -23
  94. package/lib/utils/billingLineFormData.d.ts +0 -7
  95. package/lib/utils/billingLineFormData.js +0 -63
package/README.md CHANGED
@@ -1,21 +1,13 @@
1
- - # README #
2
-
3
- ## Peer dependencies ##
4
- - "antd": "4.3.3",
5
- - "axios": "^0.19.2",
6
- - "react": "16.13.1",
7
- - "react-dom": "16.13.1",
8
- - "react-intl": "^2.9.0",
9
- - "react-intl.macro": "^0.3.7"
1
+ # README #
10
2
 
11
3
  ## Components ##
12
- ### `<CreateInvoice />` ###
4
+ ### `<CreateInvoice>` ###
13
5
 
14
6
  Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
15
7
 
16
8
  |Property |Description |Type |Default |
17
9
  |:----------------------|:------------------------------------------------------|:------------------------------------------------------|:----------|
18
- |customer |Sets the Invoice customer |Object `ProfileOutput` | |
10
+ |issuer |Sets the Invoice issuer |Object `ProfileOutput` | |
19
11
  |language |Sets the language of the component |`en` `is` `pl` `undefined` |`en` |
20
12
  |mapiBaseUrl |Url of the MAPI |string | |
21
13
  |rapiBaseUrl |Url of the RAPI |string | |
@@ -1,10 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import '@ant-design/compatible/assets/index.css';
3
- import { UploadFile } from "antd/lib/upload/interface";
4
- import { InjectedIntlProps } from "react-intl";
5
- interface Props extends InjectedIntlProps {
3
+ interface Props {
6
4
  fieldName: string;
7
- handleAddFile: (file: UploadFile) => void;
8
5
  }
9
6
  interface States {
10
7
  file: any[];
@@ -15,7 +12,4 @@ declare class Attachment extends React.Component<Props, States> {
15
12
  normFile: (e: any) => any;
16
13
  render(): JSX.Element;
17
14
  }
18
- declare const _default: React.ComponentClass<Pick<Props & React.RefAttributes<Attachment>, "key" | "ref" | "fieldName" | "handleAddFile">, any> & {
19
- WrappedComponent: React.ComponentType<Props & React.RefAttributes<Attachment> & InjectedIntlProps>;
20
- };
21
- export default _default;
15
+ export default Attachment;
@@ -34,29 +34,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  var React = __importStar(require("react"));
35
35
  require("@ant-design/compatible/assets/index.css");
36
36
  var antd_1 = require("antd");
37
- var react_intl_1 = require("react-intl");
38
- var translationMessages = react_intl_1.defineMessages({
39
- attachment_labels_Reference: {
40
- id: "attachment_labels_Reference",
41
- defaultMessage: "Reference",
42
- },
43
- attachment_labels_Reference_requiredMessage: {
44
- id: "attachment_labels_Reference_requiredMessage",
45
- defaultMessage: "Please input the reference",
46
- },
47
- attachment_labels_Description: {
48
- id: "attachment_labels_Description",
49
- defaultMessage: "Description",
50
- },
51
- attachment_labels_Description_requiredMessage: {
52
- id: "attachment_labels_Description_requiredMessage",
53
- defaultMessage: "Please input the description",
54
- },
55
- attachment_labels_File: {
56
- id: "attachment_labels_File",
57
- defaultMessage: "File",
58
- },
59
- });
60
37
  var Attachment = /** @class */ (function (_super) {
61
38
  __extends(Attachment, _super);
62
39
  function Attachment(props) {
@@ -77,27 +54,24 @@ var Attachment = /** @class */ (function (_super) {
77
54
  return _this;
78
55
  }
79
56
  Attachment.prototype.render = function () {
80
- var _this = this;
81
57
  return (React.createElement(React.Fragment, null,
82
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: this.props.intl.formatMessage(translationMessages.attachment_labels_Reference), name: "attachment:" + this.props.fieldName + ":reference", rules: [
58
+ React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "Reference", name: "attachment:" + this.props.fieldName + ":reference", rules: [
83
59
  {
84
60
  required: this.state.file.length > 0,
85
- message: this.props.intl.formatMessage(translationMessages.attachment_labels_Reference_requiredMessage),
61
+ message: 'Please input the reference',
86
62
  }
87
63
  ] },
88
64
  React.createElement(antd_1.Input, null)),
89
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: this.props.intl.formatMessage(translationMessages.attachment_labels_Description), name: "attachment:" + this.props.fieldName + ":description", rules: [
65
+ React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "Description", name: "attachment:" + this.props.fieldName + ":description", rules: [
90
66
  {
91
67
  required: this.state.file.length > 0,
92
- message: this.props.intl.formatMessage(translationMessages.attachment_labels_Description_requiredMessage),
68
+ message: 'Please input the description',
93
69
  }
94
70
  ] },
95
71
  React.createElement(antd_1.Input, null)),
96
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: this.props.intl.formatMessage(translationMessages.attachment_labels_File), name: "attachment:" + this.props.fieldName, valuePropName: "fileList", getValueFromEvent: this.normFile },
97
- React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + this.props.fieldName, multiple: false, onRemove: this.handleRemoveFile, beforeUpload: function () { return false; }, onChange: function (info) {
98
- _this.props.handleAddFile(info.file);
99
- } }))));
72
+ React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "File", name: "attachment:" + this.props.fieldName, valuePropName: "fileList", getValueFromEvent: this.normFile },
73
+ React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + this.props.fieldName, multiple: false, onRemove: this.handleRemoveFile }))));
100
74
  };
101
75
  return Attachment;
102
76
  }(React.Component));
103
- exports.default = react_intl_1.injectIntl(React.memo(Attachment));
77
+ exports.default = Attachment;
@@ -1,10 +1,3 @@
1
1
  import * as React from 'react';
2
- import { UploadFile } from "antd/lib/upload/interface";
3
- import { InjectedIntlProps } from "react-intl";
4
- interface Props extends InjectedIntlProps {
5
- handleAddFile: (file: UploadFile) => void;
6
- }
7
- declare const AttachmentGroupIntl: React.ComponentClass<Pick<Props, "handleAddFile">, any> & {
8
- WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
9
- };
10
- export default AttachmentGroupIntl;
2
+ declare const AttachmentsGroup: React.FC;
3
+ export default AttachmentsGroup;
@@ -11,21 +11,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  var React = __importStar(require("react"));
14
- var components_1 = require("../../components");
14
+ var component_container_1 = __importDefault(require("../component-container"));
15
15
  var Attachment_1 = __importDefault(require("./Attachment"));
16
- var react_intl_1 = require("react-intl");
17
- var translationMessages = react_intl_1.defineMessages({
18
- attachment_title: {
19
- id: "attachment.title",
20
- defaultMessage: "Attachments",
21
- },
22
- });
23
16
  var AttachmentsGroup = function (props) {
24
- var handleAddFile = props.handleAddFile;
25
- return (React.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.attachment_title) },
26
- React.createElement(Attachment_1.default, { handleAddFile: handleAddFile, fieldName: "file1" }),
27
- React.createElement(Attachment_1.default, { handleAddFile: handleAddFile, fieldName: "file2" }),
28
- React.createElement(Attachment_1.default, { handleAddFile: handleAddFile, fieldName: "file3" })));
17
+ return (React.createElement(component_container_1.default, { title: "Attachments" },
18
+ React.createElement(Attachment_1.default, { fieldName: "file1" }),
19
+ React.createElement(Attachment_1.default, { fieldName: "file2" }),
20
+ React.createElement(Attachment_1.default, { fieldName: "file3" })));
29
21
  };
30
- var AttachmentGroupIntl = react_intl_1.injectIntl(AttachmentsGroup);
31
- exports.default = AttachmentGroupIntl;
22
+ exports.default = AttachmentsGroup;
@@ -1,12 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import '@ant-design/compatible/assets/index.css';
3
3
  import { FormInstance } from "antd/es/form";
4
- import { InjectedIntlProps } from "react-intl";
5
- interface Props extends InjectedIntlProps {
4
+ interface Props {
6
5
  form: FormInstance;
7
6
  documentType: "creditNote" | "invoice";
8
7
  }
9
- declare const BaseInformationIntl: React.ComponentClass<Pick<Props, "form" | "documentType">, any> & {
10
- WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
11
- };
12
- export default BaseInformationIntl;
8
+ declare const BaseInformation: React.FC<Props>;
9
+ export default BaseInformation;
@@ -11,121 +11,102 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  var React = __importStar(require("react"));
14
- var components_1 = require("../../components");
14
+ var component_container_1 = __importDefault(require("../component-container"));
15
15
  require("@ant-design/compatible/assets/index.css");
16
16
  var antd_1 = require("antd");
17
- var form_item_1 = __importDefault(require("../form-item"));
18
- var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
19
- var react_intl_1 = require("react-intl");
20
- var translationMessages = react_intl_1.defineMessages({
21
- baseInformation_title: {
22
- id: "baseInformation_title",
23
- defaultMessage: "Base Information",
24
- },
25
- baseInformation_invoiceNo: {
26
- id: "baseInformation_invoiceNo",
27
- defaultMessage: "Invoice No",
28
- },
29
- baseInformation_issueDate: {
30
- id: "baseInformation_issueDate",
31
- defaultMessage: "Issue date"
32
- },
33
- baseInformation_dueDate: {
34
- id: "baseInformation_dueDate",
35
- defaultMessage: "Due date"
36
- },
37
- baseInformation_orderReference_documentNo: {
38
- id: "baseInformation_orderReference_documentNo",
39
- defaultMessage: "Order no"
40
- },
41
- baseInformation_notes: {
42
- id: "baseInformation_notes",
43
- defaultMessage: "Notes"
44
- },
45
- baseInformation_currencyCode: {
46
- id: "baseInformation_currencyCode",
47
- defaultMessage: "Currency"
48
- }
49
- });
50
17
  var BaseInformation = function (props) {
51
- var getCurrencies = function (recRequirements) {
52
- var currencies = [
53
- {
54
- key: "ISK",
55
- label: "Icelandic krona (ISK)"
56
- },
57
- {
58
- key: "DKK",
59
- label: "Danish krona (DKK)"
60
- },
61
- {
62
- key: "NOK",
63
- label: "Norwegian krona (NOK)"
64
- },
65
- {
66
- key: "SEK",
67
- label: "Swedish krona (SEK)"
68
- },
69
- {
70
- key: "EUR",
71
- label: "Euro (EUR)"
72
- },
73
- {
74
- key: "USD",
75
- label: "US dollar (USD)"
76
- },
77
- {
78
- key: "GBP",
79
- label: "British pound (GBP)"
80
- },
81
- ];
82
- if (recRequirements.currencyCode && recRequirements.currencyCode.values && recRequirements.currencyCode.values.length > 0) {
83
- return recRequirements.currencyCode.values.map(function (currency) {
84
- return React.createElement(antd_1.Select.Option, { value: currency.key, title: currency.label, key: currency.key }, currency.label);
85
- });
86
- }
87
- else {
88
- return currencies.map(function (currency) {
89
- return React.createElement(antd_1.Select.Option, { value: currency.key, title: currency.label, key: currency.key }, currency.label);
90
- });
91
- }
92
- };
18
+ var currencies = [
19
+ {
20
+ value: "ISK",
21
+ display: "Icelandic krona (ISK)"
22
+ },
23
+ {
24
+ value: "DKK",
25
+ display: "Danish krona (DKK)"
26
+ },
27
+ {
28
+ value: "NOK",
29
+ display: "Norwegian krona (NOK)"
30
+ },
31
+ {
32
+ value: "SEK",
33
+ display: "Swedish krona (SEK)"
34
+ },
35
+ {
36
+ value: "EUR",
37
+ display: "Euro (EUR)"
38
+ },
39
+ {
40
+ value: "USD",
41
+ display: "US dollar (USD)"
42
+ },
43
+ {
44
+ value: "GBP",
45
+ display: "British pound (GBP)"
46
+ },
47
+ ];
93
48
  var disabledDate = function (dueDate, issueDate) {
94
49
  return dueDate < issueDate;
95
50
  };
96
51
  var checkIfEmpty = function (date) {
97
52
  if (!date) {
98
- props.form.resetFields(["invoice", "dueDate"]);
99
- props.form.validateFields(["invoice", "dueDate"]).then(function (values) {
53
+ props.form.resetFields(props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"]);
54
+ props.form.validateFields(props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"]).then(function (values) {
100
55
  // console.log(values);
101
56
  });
102
57
  }
103
58
  };
104
- return (React.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.baseInformation_title) },
105
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.invoiceNo, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_invoiceNo), defaultIsRequired: true, fieldName: ["invoice", "invoiceNo"] },
59
+ var getDocumentNoLabel = function (documentType) {
60
+ switch (documentType) {
61
+ case "creditNote":
62
+ return "Credit note no.";
63
+ case "invoice":
64
+ return "Invoice no.";
65
+ }
66
+ };
67
+ return (React.createElement(component_container_1.default, { title: "Base information" },
68
+ React.createElement(antd_1.Form.Item, { label: getDocumentNoLabel(props.documentType), name: props.documentType === "invoice" ? ["invoice", "invoiceNo"] : ["creditNote", "invoiceNo"] },
106
69
  React.createElement(antd_1.Input, null)),
107
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.issueDate, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_issueDate), defaultIsRequired: true, fieldName: ["invoice", "issueDate"] },
108
- React.createElement(antd_1.DatePicker, null)),
109
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.dueDate, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_dueDate), defaultIsRequired: false, fieldName: ["invoice", "dueDate"], additionalRules: [
70
+ React.createElement(antd_1.Form.Item, { label: "Issue date", rules: [
110
71
  {
111
- validator: (function (rule, value, callback) {
112
- if (!value) {
113
- callback();
114
- }
115
- var issueDate = props.form.getFieldValue(["invoice", "issueDate"]);
116
- value < issueDate
117
- ? callback("Due date must be after the issue date")
118
- : callback();
119
- }),
72
+ required: true,
73
+ message: 'Please input the issue date',
120
74
  },
121
- ] },
122
- React.createElement(antd_1.DatePicker, { onChange: checkIfEmpty, disabledDate: (function (current) { return disabledDate(current, props.form.getFieldValue(["invoice", "issueDate"])); }) })),
123
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["orderReference.documentNo"], defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_orderReference_documentNo), defaultIsRequired: false, fieldName: ["invoice", "orderReference", "documentNo"] },
75
+ ], name: props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"] },
76
+ React.createElement(antd_1.DatePicker, null)),
77
+ props.documentType === "invoice" &&
78
+ React.createElement(React.Fragment, null,
79
+ React.createElement(antd_1.Form.Item, { label: "Due date", name: props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"], rules: [
80
+ {
81
+ validator: (function (rule, value, callback) {
82
+ if (!value) {
83
+ callback();
84
+ }
85
+ var issueDate = props.form.getFieldValue(props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"]);
86
+ value < issueDate
87
+ ? callback("Due date must be after the issue date")
88
+ : callback();
89
+ }),
90
+ },
91
+ ] },
92
+ React.createElement(antd_1.DatePicker, { onChange: checkIfEmpty, disabledDate: (function (current) { return disabledDate(current, props.form.getFieldValue(props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"])); }) })),
93
+ React.createElement(antd_1.Form.Item, { label: "Last payment date", name: props.documentType === "invoice" ? ["invoice", "lastPaymentDate"] : ["creditNote", "lastPaymentDate"] },
94
+ React.createElement(antd_1.DatePicker, null))),
95
+ props.documentType === "creditNote" &&
96
+ React.createElement(antd_1.Form.Item, { label: "Invoice no", name: props.documentType === "creditNote" ? ["invoice", "invoiceReferenceNo"] : ["creditNote", "invoiceReferenceNo"], rules: [
97
+ {
98
+ required: true,
99
+ message: "Please input the invoice no."
100
+ }
101
+ ] },
102
+ React.createElement(antd_1.Input, null)),
103
+ React.createElement(antd_1.Form.Item, { label: "Order no", name: props.documentType === "invoice" ? ["invoice", "orderNo"] : ["creditNote", "orderNo"] },
124
104
  React.createElement(antd_1.Input, null)),
125
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.notes, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_notes), defaultIsRequired: false, fieldName: ["invoice", "notes"] },
105
+ React.createElement(antd_1.Form.Item, { label: "Notes", name: props.documentType === "invoice" ? ["invoice", "notes"] : ["creditNote", "notes"] },
126
106
  React.createElement(antd_1.Input.TextArea, null)),
127
- React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.currencyCode, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_currencyCode), defaultIsRequired: true, fieldName: ["invoice", "currencyCode"] },
128
- React.createElement(antd_1.Select, { defaultActiveFirstOption: true }, getCurrencies(ReceiverRequirements_1.receiverRequirementsObject)))));
107
+ React.createElement(antd_1.Form.Item, { label: "Currency", name: props.documentType === "invoice" ? ["invoice", "currency"] : ["creditNote", "currency"] },
108
+ React.createElement(antd_1.Select, { defaultActiveFirstOption: true }, currencies.map(function (currency) {
109
+ return React.createElement(antd_1.Select.Option, { value: currency.value, title: currency.display, key: currency.value }, currency.display);
110
+ })))));
129
111
  };
130
- var BaseInformationIntl = react_intl_1.injectIntl(BaseInformation);
131
- exports.default = BaseInformationIntl;
112
+ exports.default = BaseInformation;
@@ -1,13 +1,27 @@
1
1
  import * as React from 'react';
2
2
  import '@ant-design/compatible/assets/index.css';
3
3
  import { BillingLineMetadata } from "@unimaze/api-clients/lib/mapi/models";
4
- import { InjectedIntlProps } from "react-intl";
4
+ import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
5
5
  import { FormInstance } from "antd/es/form";
6
- interface Props extends InjectedIntlProps {
6
+ import { ColumnType } from 'antd/es/table';
7
+ interface EditableColumnProps<T> extends ColumnType<T> {
8
+ editable?: boolean;
9
+ }
10
+ interface Props {
7
11
  formInstance: FormInstance;
8
12
  setBillingLineMetadata: (formInstance: FormInstance, billingLineMetadata: BillingLineMetadata[]) => void;
9
13
  }
10
- declare const BillingLinesIntl: React.ComponentClass<Pick<Props, "formInstance" | "setBillingLineMetadata">, any> & {
11
- WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
12
- };
13
- export default BillingLinesIntl;
14
+ interface States {
15
+ dataSource: BillingLineMetadataOverride[];
16
+ editableIndex: number;
17
+ }
18
+ declare class BillingLines extends React.Component<Props, States> {
19
+ columns: EditableColumnProps<BillingLineMetadataOverride>[];
20
+ constructor(props: Props);
21
+ renderCurrencyColumn: (text: string) => string;
22
+ handleDelete: (index: number) => void;
23
+ handleAdd: () => void;
24
+ handleSave: (row: BillingLineMetadataOverride, formInstance: FormInstance) => void;
25
+ render(): JSX.Element;
26
+ }
27
+ export default BillingLines;
@@ -35,72 +35,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  var React = __importStar(require("react"));
38
- var components_1 = require("../../components");
38
+ var component_container_1 = __importDefault(require("../component-container"));
39
39
  var icons_1 = require("@ant-design/icons");
40
40
  require("@ant-design/compatible/assets/index.css");
41
41
  var antd_1 = require("antd");
42
42
  var models_1 = require("@unimaze/api-clients/lib/mapi/models");
43
- var react_intl_1 = require("react-intl");
44
- var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
45
- var api_1 = require("@unimaze/api-clients/lib/mapi/api");
46
- var BillingCalculations_1 = __importDefault(require("./BillingCalculations"));
47
- var BillingTaxSummary_1 = __importDefault(require("./BillingTaxSummary"));
48
- var translationMessages = react_intl_1.defineMessages({
49
- billingLines_title: {
50
- id: "billingLines_title",
51
- defaultMessage: "Document lines",
52
- },
53
- billingLines_itemNo: {
54
- id: "billingLines_itemNo",
55
- defaultMessage: "Item no",
56
- },
57
- billingLines_name: {
58
- id: "billingLines_itemNo",
59
- defaultMessage: "Name"
60
- },
61
- billingLines_quantity: {
62
- id: "billingLines_quantity",
63
- defaultMessage: "Quantity"
64
- },
65
- billingLines_unitOfMeasure: {
66
- id: "billingLines_unitOfMeasure",
67
- defaultMessage: "Unit of measure"
68
- },
69
- billingLines_unitPriceAmount: {
70
- id: "billingLines_unitPriceAmount",
71
- defaultMessage: "Unit price amount"
72
- },
73
- billingLines_taxCategoryType: {
74
- id: "billingLines_taxCategoryType",
75
- defaultMessage: "Tax category"
76
- },
77
- billingLines_taxCategoryPercentage: {
78
- id: "billingLines_taxCategoryPercentage",
79
- defaultMessage: "Tax percentage"
80
- },
81
- billingLines_discount: {
82
- id: "billingLines_discount",
83
- defaultMessage: "Discount"
84
- },
85
- billingLines_lineAmount: {
86
- id: "billingLines_lineAmount",
87
- defaultMessage: "Amount"
88
- },
89
- billingLines_taxAmount: {
90
- id: "billingLines_taxAmount",
91
- defaultMessage: "Tax inclusive amount"
92
- },
93
- billingLines_button_addRow: {
94
- id: "billingLines_button_addRow",
95
- defaultMessage: "Add a row"
96
- },
97
- });
43
+ var editable_cell_1 = __importDefault(require("../editable-cell"));
44
+ var editable_row_1 = __importDefault(require("../editable-row"));
98
45
  var BillingLines = /** @class */ (function (_super) {
99
46
  __extends(BillingLines, _super);
100
47
  function BillingLines(props) {
101
48
  var _this = _super.call(this, props) || this;
102
49
  _this.renderCurrencyColumn = function (text) {
103
- var currency = _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
50
+ var currency = _this.props.formInstance.getFieldValue("baseInformation:currency") ? _this.props.formInstance.getFieldValue("baseInformation:currency") : "";
104
51
  return text + " " + currency;
105
52
  };
106
53
  _this.handleDelete = function (index) {
@@ -146,74 +93,49 @@ var BillingLines = /** @class */ (function (_super) {
146
93
  };
147
94
  _this.columns = [
148
95
  {
149
- title: _this.props.intl.formatMessage(translationMessages.billingLines_itemNo),
96
+ title: "Item No",
150
97
  dataIndex: 'itemNo',
151
98
  editable: true,
152
99
  },
153
100
  {
154
- title: _this.props.intl.formatMessage(translationMessages.billingLines_name),
101
+ title: "Name",
155
102
  dataIndex: 'name',
156
103
  editable: true,
157
104
  },
158
105
  {
159
- title: _this.props.intl.formatMessage(translationMessages.billingLines_quantity),
106
+ title: "Quantity",
160
107
  dataIndex: 'quantity',
161
108
  editable: true,
162
- align: "right",
163
109
  },
164
110
  {
165
- title: _this.props.intl.formatMessage(translationMessages.billingLines_unitOfMeasure),
111
+ title: "Unit of measure",
166
112
  dataIndex: 'unitOfMeasure',
167
113
  editable: true,
168
114
  },
169
115
  {
170
- title: _this.props.intl.formatMessage(translationMessages.billingLines_unitPriceAmount),
116
+ title: "Unit price amount",
171
117
  dataIndex: 'unitPriceAmount',
172
118
  editable: true,
173
- align: "right",
174
119
  },
175
120
  {
176
- title: _this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType),
121
+ title: "Tax category",
177
122
  dataIndex: 'taxCategoryType',
178
123
  editable: true,
179
124
  },
180
125
  {
181
- title: _this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryPercentage),
182
- dataIndex: 'taxCategoryPercentage',
183
- editable: false,
184
- align: "right",
185
- render: (function (text, record) {
186
- var taxPercentage = BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType]); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
187
- return React.createElement("span", null,
188
- taxPercentage,
189
- "%");
190
- })
191
- },
192
- {
193
- title: _this.props.intl.formatMessage(translationMessages.billingLines_discount),
126
+ title: "Discount",
194
127
  dataIndex: 'discountValue',
195
128
  editable: true,
196
- align: "right",
197
129
  },
198
130
  {
199
- title: _this.props.intl.formatMessage(translationMessages.billingLines_lineAmount),
131
+ title: "Line amount",
200
132
  dataIndex: 'taxableAmount',
201
- editable: false,
202
- align: "right",
203
- render: function (text, record) {
204
- return (React.createElement("span", null, BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount).toFixed(2)));
205
- }
206
- },
207
- {
208
- title: _this.props.intl.formatMessage(translationMessages.billingLines_taxAmount),
209
- dataIndex: 'taxInclusiveAmount',
210
- editable: false,
211
- align: "right",
212
133
  render: function (text, record) {
213
- var taxAmount = BillingLineUtility_1.calculateTaxAmount(BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount), BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType])); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
214
- var taxableAmount = BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
215
- var taxInclusiveAmount = taxableAmount + taxAmount;
216
- return (React.createElement("span", null, taxInclusiveAmount.toFixed(2)));
134
+ var lineAmount = 0;
135
+ if (record.quantity && record.unitPriceAmount) {
136
+ lineAmount = record.quantity * record.unitPriceAmount;
137
+ }
138
+ return (React.createElement("span", null, lineAmount));
217
139
  }
218
140
  },
219
141
  {
@@ -234,8 +156,8 @@ var BillingLines = /** @class */ (function (_super) {
234
156
  // console.log(dataSource);
235
157
  var components = {
236
158
  body: {
237
- row: components_1.EditableRow,
238
- cell: components_1.EditableCell,
159
+ row: editable_row_1.default,
160
+ cell: editable_cell_1.default,
239
161
  },
240
162
  };
241
163
  var columns = this.columns.map(function (col) {
@@ -250,15 +172,9 @@ var BillingLines = /** @class */ (function (_super) {
250
172
  handleSave: function (billingLineMetadataOverrideRecord, rowIndex) { return _this.handleSave(billingLineMetadataOverrideRecord, _this.props.formInstance); },
251
173
  }); } });
252
174
  });
253
- return (React.createElement(components_1.ComponentContainer, { title: this.props.intl.formatMessage(translationMessages.billingLines_title), action: React.createElement(antd_1.Button, { onClick: this.handleAdd, type: "primary", style: { marginBottom: 16 } }, this.props.intl.formatMessage(translationMessages.billingLines_button_addRow)) },
254
- React.createElement(antd_1.Table, { style: { minHeight: "170px" }, components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: (function (record, index) { return index.toString(); }) }),
255
- React.createElement(antd_1.Row, { style: { marginTop: "1em" }, align: "top", justify: "space-between", gutter: [16, 16] },
256
- React.createElement(antd_1.Col, { span: 16 },
257
- React.createElement(BillingTaxSummary_1.default, { billingLines: dataSource })),
258
- React.createElement(antd_1.Col, { span: 8 },
259
- React.createElement(BillingCalculations_1.default, { billingLinesMetadata: dataSource, renderCurrencyColumn: this.renderCurrencyColumn })))));
175
+ return (React.createElement(component_container_1.default, { title: "Document Lines", action: React.createElement(antd_1.Button, { onClick: this.handleAdd, type: "primary", style: { marginBottom: 16 } }, "Add a row") },
176
+ React.createElement(antd_1.Table, { components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: (function (record, index) { return index.toString(); }) })));
260
177
  };
261
178
  return BillingLines;
262
179
  }(React.Component));
263
- var BillingLinesIntl = react_intl_1.injectIntl(BillingLines);
264
- exports.default = BillingLinesIntl;
180
+ exports.default = BillingLines;
@@ -0,0 +1 @@
1
+ import "./index.css";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./index.css");
@@ -1,6 +1,3 @@
1
1
  import * as React from 'react';
2
- import { InjectedIntlProps } from "react-intl";
3
- declare const DeliveryLocationIntl: React.ComponentClass<Pick<InjectedIntlProps, never>, any> & {
4
- WrappedComponent: React.ComponentType<InjectedIntlProps>;
5
- };
6
- export default DeliveryLocationIntl;
2
+ declare const DeliveryLocation: React.FC;
3
+ export default DeliveryLocation;