@unimaze/billing 0.1.1 → 0.1.2-rc.10

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 (101) hide show
  1. package/README.md +11 -3
  2. package/lib/common/components/attachments/Attachment.d.ts +8 -2
  3. package/lib/common/components/attachments/Attachment.js +33 -8
  4. package/lib/common/components/attachments/index.d.ts +9 -2
  5. package/lib/common/components/attachments/index.js +15 -6
  6. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +6 -0
  7. package/lib/common/components/base-information/ReferenceIdentifiers.js +40 -0
  8. package/lib/common/components/base-information/index.d.ts +6 -3
  9. package/lib/common/components/base-information/index.js +100 -81
  10. package/lib/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  11. package/lib/common/components/billing-lines/BillingCalculations.js +61 -0
  12. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  13. package/lib/common/components/billing-lines/BillingTaxSummary.js +51 -0
  14. package/lib/common/components/billing-lines/billingLIneFormData.d.ts +7 -0
  15. package/lib/common/components/billing-lines/billingLIneFormData.js +63 -0
  16. package/lib/common/components/billing-lines/index.d.ts +9 -23
  17. package/lib/common/components/billing-lines/index.js +116 -38
  18. package/lib/common/components/customer/hardCoddedCustomer.d.ts +7 -0
  19. package/lib/common/components/{issuer/index.js → customer/hardCoddedCustomer.js} +5 -8
  20. package/lib/common/components/customer/index.d.ts +6 -0
  21. package/lib/common/components/customer/index.js +93 -0
  22. package/lib/common/components/delivery-location/index.d.ts +5 -2
  23. package/lib/common/components/delivery-location/index.js +43 -11
  24. package/lib/common/components/editable-cell/index.d.ts +1 -1
  25. package/lib/common/components/editable-cell/index.js +76 -10
  26. package/lib/common/components/editable-row/index.d.ts +5 -5
  27. package/lib/common/components/editable-row/index.js +8 -6
  28. package/lib/common/components/form-item/index.d.ts +21 -0
  29. package/lib/common/components/form-item/index.js +27 -0
  30. package/lib/common/components/index.d.ts +10 -5
  31. package/lib/common/components/index.js +20 -8
  32. package/lib/common/components/locale-intl/index.d.ts +10 -0
  33. package/lib/common/components/locale-intl/index.js +45 -0
  34. package/lib/common/components/payment-method/index.d.ts +6 -3
  35. package/lib/common/components/payment-method/index.js +67 -27
  36. package/lib/common/components/supplier/index.d.ts +6 -0
  37. package/lib/common/components/supplier/index.js +93 -0
  38. package/lib/common/consts/validationRules.d.ts +2 -3
  39. package/lib/common/consts/validationRules.js +0 -7
  40. package/lib/common/enums/index.d.ts +1 -1
  41. package/lib/common/enums/index.js +2 -4
  42. package/lib/common/types/BillingLineMetadataOverride.d.ts +1 -0
  43. package/lib/common/types/ReceiverRequirements.d.ts +81 -0
  44. package/lib/common/types/ReceiverRequirements.js +379 -0
  45. package/lib/create-credit-note/index.d.ts +2 -3
  46. package/lib/create-credit-note/index.js +17 -28
  47. package/lib/create-invoice/index.d.ts +1 -2
  48. package/lib/create-invoice/index.js +79 -21
  49. package/lib/example/src/index.d.ts +1 -1
  50. package/lib/index.d.ts +2 -3
  51. package/lib/index.js +8 -5
  52. package/lib/src/common/components/attachments/Attachment.d.ts +21 -0
  53. package/lib/src/common/components/attachments/index.d.ts +10 -0
  54. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +6 -0
  55. package/lib/src/common/components/base-information/index.d.ts +12 -0
  56. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  57. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  58. package/lib/src/common/components/billing-lines/billingLIneFormData.d.ts +7 -0
  59. package/lib/src/common/components/billing-lines/index.d.ts +13 -0
  60. package/lib/src/common/components/component-container/Content.d.ts +7 -0
  61. package/lib/src/common/components/component-container/Header.d.ts +9 -0
  62. package/lib/src/common/components/component-container/index.d.ts +10 -0
  63. package/lib/src/common/components/customer/index.d.ts +6 -0
  64. package/lib/src/common/components/delivery-location/index.d.ts +6 -0
  65. package/lib/src/common/components/editable-cell/index.d.ts +11 -0
  66. package/lib/src/common/components/editable-row/index.d.ts +6 -0
  67. package/lib/src/common/components/form-item/index.d.ts +21 -0
  68. package/lib/src/common/components/index.d.ts +10 -0
  69. package/lib/src/common/components/locale-intl/index.d.ts +10 -0
  70. package/lib/src/common/components/payment-method/index.d.ts +6 -0
  71. package/lib/src/common/components/supplier/index.d.ts +6 -0
  72. package/lib/src/common/consts/validationRules.d.ts +6 -0
  73. package/lib/src/common/types/ReceiverRequirements.d.ts +81 -0
  74. package/lib/src/create-invoice/index.d.ts +14 -0
  75. package/lib/src/translations/locales.d.ts +74 -0
  76. package/lib/src/utils/ApiUtility.d.ts +21 -0
  77. package/lib/src/utils/BillingLineUtility.d.ts +8 -0
  78. package/lib/src/utils/ConversionUtility.d.ts +5 -0
  79. package/lib/src/utils/RequirementsUtility.d.ts +5 -0
  80. package/lib/src/utils/billingLineFormData.d.ts +7 -0
  81. package/lib/src/utils/index.d.ts +2 -0
  82. package/lib/style/index.css +0 -1222
  83. package/lib/translations/locales/is.json +70 -0
  84. package/lib/translations/locales.d.ts +74 -0
  85. package/lib/translations/locales.js +10 -0
  86. package/lib/utils/ApiUtility.d.ts +21 -0
  87. package/lib/utils/ApiUtility.js +59 -0
  88. package/lib/utils/BillingLineUtility.d.ts +8 -0
  89. package/lib/utils/BillingLineUtility.js +66 -0
  90. package/lib/utils/ConversionUtility.d.ts +5 -0
  91. package/lib/utils/ConversionUtility.js +146 -0
  92. package/lib/utils/RequirementsUtility.d.ts +5 -0
  93. package/lib/utils/RequirementsUtility.js +23 -0
  94. package/lib/utils/billingLineFormData.d.ts +7 -0
  95. package/lib/utils/billingLineFormData.js +63 -0
  96. package/lib/utils/index.d.ts +2 -5
  97. package/lib/utils/index.js +5 -162
  98. package/package.json +13 -8
  99. package/lib/common/components/issuer/index.d.ts +0 -7
  100. package/lib/common/components/payer/index.d.ts +0 -3
  101. package/lib/common/components/payer/index.js +0 -50
@@ -1,27 +1,13 @@
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 { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
4
+ import { InjectedIntlProps } from "react-intl";
5
5
  import { FormInstance } from "antd/es/form";
6
- import { ColumnType } from 'antd/es/table';
7
- interface EditableColumnProps<T> extends ColumnType<T> {
8
- editable?: boolean;
9
- }
10
- interface Props {
11
- form: FormInstance;
12
- setBillingLineMetadata: (form: FormInstance, billingLineMetadata: BillingLineMetadata[]) => void;
13
- }
14
- interface States {
15
- dataSource: BillingLineMetadataOverride[];
16
- editableIndex: number | null;
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, form: FormInstance) => void;
25
- render(): JSX.Element;
26
- }
27
- export default BillingLines;
6
+ interface Props extends InjectedIntlProps {
7
+ formInstance: FormInstance;
8
+ setBillingLineMetadata: (formInstance: FormInstance, billingLineMetadata: BillingLineMetadata[]) => void;
9
+ }
10
+ declare const BillingLinesIntl: React.ComponentClass<Pick<Props, "formInstance" | "setBillingLineMetadata">, any> & {
11
+ WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
12
+ };
13
+ export default BillingLinesIntl;
@@ -35,33 +35,87 @@ 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 component_container_1 = __importDefault(require("../component-container"));
38
+ var components_1 = require("../../components");
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 editable_cell_1 = __importDefault(require("../editable-cell"));
44
- var editable_row_1 = __importDefault(require("../editable-row"));
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
+ });
45
98
  var BillingLines = /** @class */ (function (_super) {
46
99
  __extends(BillingLines, _super);
47
100
  function BillingLines(props) {
48
101
  var _this = _super.call(this, props) || this;
49
102
  _this.renderCurrencyColumn = function (text) {
50
- var currency = _this.props.form.getFieldValue("baseInformation:currency") ? _this.props.form.getFieldValue("baseInformation:currency") : "";
103
+ var currency = _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
51
104
  return text + " " + currency;
52
105
  };
53
106
  _this.handleDelete = function (index) {
54
- var newDataSource = _this.state.dataSource;
107
+ var newDataSource = _this.state.dataSource.slice();
55
108
  newDataSource.splice(index, 1);
56
109
  _this.setState(function (prevState) { return (__assign({}, prevState, { dataSource: newDataSource })); });
57
110
  };
58
111
  _this.handleAdd = function () {
59
112
  var dataSource = _this.state.dataSource;
60
113
  var newData = {
114
+ key: _this.state.editableIndex,
61
115
  itemNo: "Item No.",
62
116
  quantity: 0,
63
117
  taxAmount: 0,
64
- name: "New item",
118
+ name: "New Item",
65
119
  unitOfMeasure: models_1.UnitOfMeasureMetadataUnitEnum.Piece,
66
120
  unitPriceAmount: 0,
67
121
  taxCategoryType: models_1.BillingLineMetadataTaxCategoryTypeEnum.StandardRated,
@@ -69,12 +123,12 @@ var BillingLines = /** @class */ (function (_super) {
69
123
  taxableAmount: 0,
70
124
  taxPercentage: null
71
125
  };
72
- _this.setState(function (prevState) { return (__assign({}, prevState, { dataSource: prevState.dataSource.concat([newData]), editableIndex: prevState.dataSource.length + 1 })); });
126
+ _this.setState(__assign({}, _this.state, { dataSource: dataSource.concat([newData]), editableIndex: _this.state.editableIndex + 1 }));
73
127
  };
74
- _this.handleSave = function (row, form) {
128
+ _this.handleSave = function (row, formInstance) {
75
129
  var newData = _this.state.dataSource.slice();
76
130
  var index = newData.findIndex(function (i) {
77
- return row.itemNo === i.itemNo;
131
+ return row.key === i.key;
78
132
  });
79
133
  var item = newData[index];
80
134
  newData.splice(index, 1, __assign({}, item, row));
@@ -83,58 +137,83 @@ var BillingLines = /** @class */ (function (_super) {
83
137
  unit: current.unitOfMeasure,
84
138
  } });
85
139
  });
86
- _this.setState({ dataSource: newData });
87
- _this.props.setBillingLineMetadata(form, billingLineMetadata);
140
+ _this.setState(__assign({}, _this.state, { dataSource: newData }));
141
+ _this.props.setBillingLineMetadata(formInstance, billingLineMetadata);
88
142
  };
89
143
  _this.state = {
90
144
  dataSource: [],
91
- editableIndex: null,
145
+ editableIndex: 0,
92
146
  };
93
147
  _this.columns = [
94
148
  {
95
- title: "Item No",
149
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_itemNo),
96
150
  dataIndex: 'itemNo',
97
151
  editable: true,
98
152
  },
99
153
  {
100
- title: "Name",
154
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_name),
101
155
  dataIndex: 'name',
102
156
  editable: true,
103
157
  },
104
158
  {
105
- title: "Quantity",
159
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_quantity),
106
160
  dataIndex: 'quantity',
107
161
  editable: true,
162
+ align: "right",
108
163
  },
109
164
  {
110
- title: "Unit of measure",
165
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_unitOfMeasure),
111
166
  dataIndex: 'unitOfMeasure',
112
167
  editable: true,
113
168
  },
114
169
  {
115
- title: "Unit price amount",
170
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_unitPriceAmount),
116
171
  dataIndex: 'unitPriceAmount',
117
172
  editable: true,
173
+ align: "right",
118
174
  },
119
175
  {
120
- title: "Tax category",
176
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType),
121
177
  dataIndex: 'taxCategoryType',
122
178
  editable: true,
123
179
  },
124
180
  {
125
- title: "Discount",
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
194
  dataIndex: 'discountValue',
127
195
  editable: true,
196
+ align: "right",
128
197
  },
129
198
  {
130
- title: "Line amount",
199
+ title: _this.props.intl.formatMessage(translationMessages.billingLines_lineAmount),
131
200
  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",
132
212
  render: function (text, record) {
133
- var lineAmount = 0;
134
- if (record.quantity && record.unitPriceAmount) {
135
- lineAmount = record.quantity * record.unitPriceAmount;
136
- }
137
- return (React.createElement("span", null, lineAmount));
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)));
138
217
  }
139
218
  },
140
219
  {
@@ -155,8 +234,8 @@ var BillingLines = /** @class */ (function (_super) {
155
234
  // console.log(dataSource);
156
235
  var components = {
157
236
  body: {
158
- row: editable_row_1.default,
159
- cell: editable_cell_1.default,
237
+ row: components_1.EditableRow,
238
+ cell: components_1.EditableCell,
160
239
  },
161
240
  };
162
241
  var columns = this.columns.map(function (col) {
@@ -168,19 +247,18 @@ var BillingLines = /** @class */ (function (_super) {
168
247
  editable: col.editable,
169
248
  dataIndex: col.dataIndex,
170
249
  title: col.title ? col.title.toString() : "",
171
- handleSave: _this.handleSave,
250
+ handleSave: function (billingLineMetadataOverrideRecord, rowIndex) { return _this.handleSave(billingLineMetadataOverrideRecord, _this.props.formInstance); },
172
251
  }); } });
173
252
  });
174
- 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") },
175
- React.createElement(antd_1.Table, { components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: function (record, index) {
176
- if (index) {
177
- return (index.toString());
178
- }
179
- else {
180
- return Math.random().toString();
181
- }
182
- } })));
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 })))));
183
260
  };
184
261
  return BillingLines;
185
262
  }(React.Component));
186
- exports.default = BillingLines;
263
+ var BillingLinesIntl = react_intl_1.injectIntl(BillingLines);
264
+ exports.default = BillingLinesIntl;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { wapi2 } from "@unimaze/api-clients";
3
+ interface Props {
4
+ customer: wapi2.ProfileOutput;
5
+ }
6
+ declare const Customer: React.FC<Props>;
7
+ export default Customer;
@@ -6,15 +6,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
6
6
  result["default"] = mod;
7
7
  return result;
8
8
  };
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  var React = __importStar(require("react"));
14
- var component_container_1 = __importDefault(require("../component-container"));
15
- var Issuer = function (props) {
16
- var _a = props.issuer, participantLegalIsoIdentifier = _a.participantLegalIsoIdentifier, participantLegalAddressPostalCode = _a.participantLegalAddressPostalCode, participantLegalAddressCity = _a.participantLegalAddressCity, participantLegalAddressStreet = _a.participantLegalAddressStreet, email = _a.email, name = _a.name, country = _a.country;
17
- return (React.createElement(component_container_1.default, { title: "Issuer" },
11
+ var components_1 = require("../../components");
12
+ var Customer = function (props) {
13
+ var _a = props.customer, participantLegalIsoIdentifier = _a.participantLegalIsoIdentifier, participantLegalAddressPostalCode = _a.participantLegalAddressPostalCode, participantLegalAddressCity = _a.participantLegalAddressCity, participantLegalAddressStreet = _a.participantLegalAddressStreet, email = _a.email, name = _a.name, country = _a.country;
14
+ return (React.createElement(components_1.ComponentContainer, { title: "Invoice payer" },
18
15
  React.createElement("div", null,
19
16
  React.createElement("strong", null, name),
20
17
  " (",
@@ -25,4 +22,4 @@ var Issuer = function (props) {
25
22
  React.createElement("div", null, country),
26
23
  React.createElement("div", null, email)));
27
24
  };
28
- exports.default = Issuer;
25
+ exports.default = Customer;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { InjectedIntlProps } from "react-intl";
3
+ declare const CustomerIntl: React.ComponentClass<Pick<InjectedIntlProps, never>, any> & {
4
+ WrappedComponent: React.ComponentType<InjectedIntlProps>;
5
+ };
6
+ export default CustomerIntl;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importStar = (this && this.__importStar) || function (mod) {
3
+ if (mod && mod.__esModule) return mod;
4
+ var result = {};
5
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
+ result["default"] = mod;
7
+ return result;
8
+ };
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ var React = __importStar(require("react"));
14
+ var components_1 = require("../../components");
15
+ var antd_1 = require("antd");
16
+ var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
17
+ var form_item_1 = __importDefault(require("../form-item"));
18
+ var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
19
+ var react_intl_1 = require("react-intl");
20
+ var translationMessages = react_intl_1.defineMessages({
21
+ customer_title: {
22
+ id: "customer_title",
23
+ defaultMessage: "Customer",
24
+ },
25
+ customer_name: {
26
+ id: "customer_name",
27
+ defaultMessage: "Name",
28
+ },
29
+ customer_identifier: {
30
+ id: "customer_identifier",
31
+ defaultMessage: "Identifier"
32
+ },
33
+ customer_address_streetNameAndNumber: {
34
+ id: "customer_address_streetNameAndNumber",
35
+ defaultMessage: "Address"
36
+ },
37
+ customer_address_zip_postalCode: {
38
+ id: "customer_address_zipPostalCode",
39
+ defaultMessage: "Zip/Postal code"
40
+ },
41
+ customer_address_city: {
42
+ id: "customer_address_city",
43
+ defaultMessage: "City"
44
+ },
45
+ customer_address_countryCode: {
46
+ id: "customer_address_countryCode",
47
+ defaultMessage: "Country code"
48
+ },
49
+ customer_contact_email: {
50
+ id: "customer_contact_email",
51
+ defaultMessage: "E-Mail"
52
+ },
53
+ customer_contact_name: {
54
+ id: "customer_contact_name",
55
+ defaultMessage: "Contact name"
56
+ }
57
+ });
58
+ var Customer = function (props) {
59
+ return (React.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.customer_title) },
60
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.name"], defaultLabel: props.intl.formatMessage(translationMessages.customer_name), defaultIsRequired: true, fieldName: ["invoice", "customer", "name"], additionalRules: [
61
+ {
62
+ required: RequirementsUtility_1.getReceiverRequirements(ReceiverRequirements_1.receiverRequirementsObject, ReceiverRequirements_1.AvailableFields["customer.name"]).isRequired,
63
+ message: 'Please input customer name',
64
+ },
65
+ ] },
66
+ React.createElement(antd_1.Input, null)),
67
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.identifier"], defaultLabel: props.intl.formatMessage(translationMessages.customer_identifier), defaultIsRequired: true, fieldName: ["invoice", "customer", "identifier"], additionalRules: [
68
+ {
69
+ required: RequirementsUtility_1.getReceiverRequirements(ReceiverRequirements_1.receiverRequirementsObject, ReceiverRequirements_1.AvailableFields["customer.identifier"]).isRequired,
70
+ message: 'Please input customer identifier',
71
+ },
72
+ ] },
73
+ React.createElement(antd_1.Input, null)),
74
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.address.streetNameAndNumber"], defaultLabel: props.intl.formatMessage(translationMessages.customer_address_streetNameAndNumber), defaultIsRequired: true, fieldName: ["invoice", "customer", "address", "streetNameAndNumber"] },
75
+ React.createElement(antd_1.Input, null)),
76
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.address.postalZone"], defaultLabel: props.intl.formatMessage(translationMessages.customer_address_zip_postalCode), defaultIsRequired: false, fieldName: ["invoice", "customer", "address", "postalZone"] },
77
+ React.createElement(antd_1.Input, null)),
78
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.address.city"], defaultLabel: props.intl.formatMessage(translationMessages.customer_address_city), defaultIsRequired: false, fieldName: ["invoice", "customer", "address", "city"] },
79
+ React.createElement(antd_1.Input, null)),
80
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.address.countryCode"], defaultLabel: props.intl.formatMessage(translationMessages.customer_address_countryCode), defaultIsRequired: true, fieldName: ["invoice", "customer", "address", "countryCode"] },
81
+ React.createElement(antd_1.Input, { disabled: true })),
82
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.contact.electronicMail"], defaultLabel: props.intl.formatMessage(translationMessages.customer_contact_email), defaultIsRequired: false, fieldName: ["invoice", "customer", "contact", "electronicMail"], additionalRules: [
83
+ {
84
+ type: 'email',
85
+ message: 'The input is not valid E-mail!',
86
+ }
87
+ ] },
88
+ React.createElement(antd_1.Input, null)),
89
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.contact.name"], defaultLabel: props.intl.formatMessage(translationMessages.customer_contact_name), defaultIsRequired: false, fieldName: ["invoice", "customer", "contact", "name"] },
90
+ React.createElement(antd_1.Input, null))));
91
+ };
92
+ var CustomerIntl = react_intl_1.injectIntl(Customer);
93
+ exports.default = CustomerIntl;
@@ -1,3 +1,6 @@
1
1
  import * as React from 'react';
2
- declare const DeliveryLocation: React.FC;
3
- export default DeliveryLocation;
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;
@@ -11,18 +11,50 @@ 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 component_container_1 = __importDefault(require("../component-container"));
14
+ var components_1 = require("../../components");
15
15
  var antd_1 = require("antd");
16
- var DeliveryLocation = function () {
17
- return (React.createElement(component_container_1.default, { title: "Delivery location" },
18
- React.createElement(antd_1.Form.Item, { label: "Description", name: "deliveryLocation:description" },
16
+ var form_item_1 = __importDefault(require("../form-item"));
17
+ var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
18
+ var react_intl_1 = require("react-intl");
19
+ // import {defineMessages} from "react-intl.macro"
20
+ var translationMessages = react_intl_1.defineMessages({
21
+ deliveryLocation_title: {
22
+ id: "deliveryLocation_title",
23
+ defaultMessage: "Delivery location",
24
+ },
25
+ deliveryLocation_partyName: {
26
+ id: "deliveryLocation_partyName",
27
+ defaultMessage: "Party name",
28
+ },
29
+ deliveryLocation_streetNameAndNumber: {
30
+ id: "deliveryLocation_streetNameAndNumber",
31
+ defaultMessage: "Address"
32
+ },
33
+ deliveryLocation_postalZone: {
34
+ id: "deliveryLocation_postalZone",
35
+ defaultMessage: "Postal no"
36
+ },
37
+ deliveryLocation_city: {
38
+ id: "deliveryLocation_city",
39
+ defaultMessage: "Town/City"
40
+ },
41
+ deliveryLocation_countryCode: {
42
+ id: "deliveryLocation_countryCode",
43
+ defaultMessage: "Country code"
44
+ }
45
+ });
46
+ var DeliveryLocation = function (props) {
47
+ return (React.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.deliveryLocation_title) },
48
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["delivery.partyName"], defaultLabel: props.intl.formatMessage(translationMessages.deliveryLocation_partyName), defaultIsRequired: false, fieldName: ["invoice", "delivery", "partyName"] },
19
49
  React.createElement(antd_1.Input, null)),
20
- React.createElement(antd_1.Form.Item, { label: "Address", name: "deliveryLocation:address" },
50
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["delivery.address.streetNameAndNumber"], defaultLabel: props.intl.formatMessage(translationMessages.deliveryLocation_streetNameAndNumber), defaultIsRequired: false, fieldName: ["invoice", "delivery", "address", "streetNameAndNumber"] },
21
51
  React.createElement(antd_1.Input, null)),
22
- React.createElement(antd_1.Form.Item, { label: "Post no., town/city", style: { marginBottom: 0 } },
23
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: "deliveryLocation:postNo" },
24
- React.createElement(antd_1.Input, null)),
25
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: "deliveryLocation:city" },
26
- React.createElement(antd_1.Input, null)))));
52
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["delivery.address.postalZone"], defaultLabel: props.intl.formatMessage(translationMessages.deliveryLocation_postalZone), defaultIsRequired: false, fieldName: ["invoice", "delivery", "address", "postalZone"] },
53
+ React.createElement(antd_1.Input, null)),
54
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["delivery.address.city"], defaultLabel: props.intl.formatMessage(translationMessages.deliveryLocation_city), defaultIsRequired: false, fieldName: ["invoice", "delivery", "address", "city"] },
55
+ React.createElement(antd_1.Input, null)),
56
+ React.createElement(form_item_1.default, { receiverRequirements: ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["delivery.address.countryCode"], defaultLabel: props.intl.formatMessage(translationMessages.deliveryLocation_countryCode), defaultIsRequired: true, fieldName: ["invoice", "delivery", "address", "countryCode"] },
57
+ React.createElement(antd_1.Input, null))));
27
58
  };
28
- exports.default = DeliveryLocation;
59
+ var DeliveryLocationIntl = react_intl_1.injectIntl(DeliveryLocation);
60
+ exports.default = DeliveryLocationIntl;
@@ -3,7 +3,7 @@ import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOver
3
3
  interface EditableCellProps {
4
4
  record: BillingLineMetadataOverride;
5
5
  handleSave: (billingLineMetadata: BillingLineMetadataOverride) => void;
6
- dataIndex: keyof BillingLineMetadataOverride;
6
+ dataIndex: keyof Omit<BillingLineMetadataOverride, 'key'>;
7
7
  editable: boolean;
8
8
  index: number;
9
9
  }
@@ -10,6 +10,41 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
13
48
  var __rest = (this && this.__rest) || function (s, e) {
14
49
  var t = {};
15
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -28,6 +63,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
63
  result["default"] = mod;
29
64
  return result;
30
65
  };
66
+ var _this = this;
31
67
  Object.defineProperty(exports, "__esModule", { value: true });
32
68
  var react_1 = __importStar(require("react"));
33
69
  var antd_1 = require("antd");
@@ -40,36 +76,66 @@ var EditableCell = function (props) {
40
76
  record = props.record, index = props.index, handleSave = props.handleSave, children = props.children, restProps = __rest(props, ["editable", "dataIndex", "record", "index", "handleSave", "children"]);
41
77
  var _a = react_1.useState(false), editing = _a[0], setEditing = _a[1];
42
78
  var input = null;
79
+ var form = react_1.useContext(editable_row_1.EditableContext);
43
80
  var toggleEdit = function () {
44
81
  setEditing(!editing);
45
82
  if (!editing && input)
46
83
  input.focus();
47
84
  };
85
+ var save = function () { return __awaiter(_this, void 0, void 0, function () {
86
+ var values, errInfo_1;
87
+ return __generator(this, function (_a) {
88
+ switch (_a.label) {
89
+ case 0:
90
+ _a.trys.push([0, 2, , 3]);
91
+ return [4 /*yield*/, form.validateFields()];
92
+ case 1:
93
+ values = _a.sent();
94
+ toggleEdit();
95
+ handleSave(__assign({}, record, values));
96
+ return [3 /*break*/, 3];
97
+ case 2:
98
+ errInfo_1 = _a.sent();
99
+ // tslint:disable-next-line:no-console
100
+ console.log('Save failed:', errInfo_1);
101
+ return [3 /*break*/, 3];
102
+ case 3: return [2 /*return*/];
103
+ }
104
+ });
105
+ }); };
48
106
  var getCorrectInputNode = function (dataIdx) {
49
107
  switch (dataIdx) {
50
108
  case "quantity":
51
109
  case "unitPriceAmount":
52
- case "taxableAmount":
53
- case "taxAmount":
54
- case "taxPercentage":
110
+ return react_1.default.createElement(antd_1.InputNumber, { step: 1,
111
+ // ref={node => (input = node)}
112
+ // onPressEnter={save}
113
+ onBlur: save });
55
114
  case "discountValue":
56
- case "accountingCost":
57
- return react_1.default.createElement(antd_1.InputNumber, { step: 0.01 });
115
+ return react_1.default.createElement(antd_1.Input, { onBlur: save });
58
116
  case "unitOfMeasure":
59
- return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true }, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
60
- return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, unitOfMeasure));
117
+ return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
118
+ // onSelect={save}
119
+ onChange: save }, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
120
+ if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
121
+ return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, unitOfMeasure));
61
122
  })));
62
123
  case "taxCategoryType":
63
- return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true }, Object.keys(models_1.BillingLineMetadataTaxCategoryTypeEnum).map(function (taxCategoryType) {
124
+ return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
125
+ // onSelect={save}
126
+ onChange: save }, Object.keys(models_1.BillingLineMetadataTaxCategoryTypeEnum).map(function (taxCategoryType) {
64
127
  return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
65
128
  })));
66
129
  default:
67
- return react_1.default.createElement(antd_1.Input, { ref: function (node) { return (input = node); } });
130
+ return react_1.default.createElement(antd_1.Input, { ref: function (node) { return (input = node); },
131
+ // onPressEnter={save}
132
+ onBlur: save });
68
133
  }
69
134
  };
70
135
  var renderCell = function () {
71
136
  var inputNode = getCorrectInputNode(dataIndex);
72
- return editing ? (react_1.default.createElement(antd_1.Form.Item, { style: { margin: 0 }, rules: validationRules_1.validationRules[dataIndex], name: dataIndex, initialValue: record[dataIndex] }, inputNode)) : (react_1.default.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24 }, onClick: toggleEdit }, children));
137
+ var rules = validationRules_1.validationRules[dataIndex];
138
+ return editing ? (react_1.default.createElement(antd_1.Form.Item, { style: { margin: 0 }, rules: rules, name: dataIndex, initialValue: record[dataIndex] }, inputNode)) : (react_1.default.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24 }, onClick: toggleEdit }, children));
73
139
  };
74
140
  return (react_1.default.createElement("td", __assign({}, restProps), editable ? (react_1.default.createElement(editable_row_1.EditableContext.Consumer, null, renderCell)) : (children)));
75
141
  };