@unimaze/billing 0.3.3 → 0.3.5-sjova.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/lib/common/components/attachments/Attachment.js +15 -12
  2. package/lib/common/components/attachments/index.js +12 -11
  3. package/lib/common/components/base-information/ReferenceIdentifiers.js +24 -14
  4. package/lib/common/components/base-information/index.js +66 -39
  5. package/lib/common/components/billing-lines/BillingCalculations.d.ts +2 -2
  6. package/lib/common/components/billing-lines/BillingCalculations.js +8 -7
  7. package/lib/common/components/billing-lines/BillingTaxSummary.js +33 -5
  8. package/lib/common/components/billing-lines/index.d.ts +10 -1
  9. package/lib/common/components/billing-lines/index.js +74 -41
  10. package/lib/common/components/customer/index.d.ts +1 -1
  11. package/lib/common/components/customer/index.js +5 -11
  12. package/lib/common/components/editable-cell/index.d.ts +7 -3
  13. package/lib/common/components/editable-cell/index.js +131 -8
  14. package/lib/common/components/form-item/index.d.ts +4 -2
  15. package/lib/common/components/form-item/index.js +27 -7
  16. package/lib/common/components/payment-method/index.js +38 -62
  17. package/lib/common/components/payment-method/paymentMethodForConversion.js +2 -11
  18. package/lib/common/components/supplier/index.js +18 -35
  19. package/lib/common/consts/formLayout.d.ts +30 -0
  20. package/lib/common/consts/formLayout.js +9 -0
  21. package/lib/common/consts/validationRules.d.ts +2 -2
  22. package/lib/common/consts/validationRules.js +11 -8
  23. package/lib/common/types/AppConfiguration.d.ts +1 -1
  24. package/lib/common/types/BillingLineMetadataOverride.d.ts +5 -3
  25. package/lib/common/types/CommonProps.d.ts +1 -1
  26. package/lib/common/types/ReceiverRequirements.js +1 -1
  27. package/lib/create-invoice/IntlLoader.js +49 -0
  28. package/lib/create-invoice/index.d.ts +7 -10
  29. package/lib/create-invoice/index.js +110 -69
  30. package/lib/translations/locales/is.json +65 -4
  31. package/lib/translations/locales.d.ts +62 -1
  32. package/lib/utils/BillingLineUtility.d.ts +2 -2
  33. package/lib/utils/BillingLineUtility.js +2 -2
  34. package/lib/utils/FormatingUtility.d.ts +2 -0
  35. package/lib/utils/FormatingUtility.js +6 -0
  36. package/lib/utils/IntlUtility.d.ts +4 -0
  37. package/lib/utils/IntlUtility.js +54 -0
  38. package/package.json +3 -9
  39. package/lib/common/types/Configuration.d.ts +0 -14
  40. package/lib/common/types/Configuration.js +0 -2
  41. package/lib/example/src/index.d.ts +0 -1
  42. package/lib/src/common/components/attachments/Attachment.d.ts +0 -18
  43. package/lib/src/common/components/attachments/index.d.ts +0 -6
  44. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +0 -17
  45. package/lib/src/common/components/base-information/index.d.ts +0 -11
  46. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +0 -11
  47. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +0 -10
  48. package/lib/src/common/components/billing-lines/NewBillingLines.d.ts +0 -10
  49. package/lib/src/common/components/billing-lines/index.d.ts +0 -19
  50. package/lib/src/common/components/component-container/Content.d.ts +0 -7
  51. package/lib/src/common/components/component-container/Header.d.ts +0 -9
  52. package/lib/src/common/components/component-container/index.d.ts +0 -11
  53. package/lib/src/common/components/customer/index.d.ts +0 -16
  54. package/lib/src/common/components/delivery-location/index.d.ts +0 -6
  55. package/lib/src/common/components/editable-cell/index.d.ts +0 -11
  56. package/lib/src/common/components/editable-row/index.d.ts +0 -5
  57. package/lib/src/common/components/form-item/index.d.ts +0 -23
  58. package/lib/src/common/components/index.d.ts +0 -10
  59. package/lib/src/common/components/locale-intl/index.d.ts +0 -10
  60. package/lib/src/common/components/payment-method/index.d.ts +0 -6
  61. package/lib/src/common/components/payment-method/paymentMethodForConversion.d.ts +0 -9
  62. package/lib/src/common/components/supplier/index.d.ts +0 -10
  63. package/lib/src/common/consts/formLayout.d.ts +0 -44
  64. package/lib/src/common/consts/validationRules.d.ts +0 -6
  65. package/lib/src/common/types/ReceiverRequirements.d.ts +0 -81
  66. package/lib/src/translations/locales.d.ts +0 -78
  67. package/lib/src/utils/ApiUtility.d.ts +0 -21
  68. package/lib/src/utils/BillingLineUtility.d.ts +0 -10
  69. package/lib/src/utils/ConversionUtility.d.ts +0 -8
  70. package/lib/src/utils/RequirementsUtility.d.ts +0 -5
  71. package/lib/src/utils/index.d.ts +0 -2
  72. /package/lib/{src/create-invoice/index.d.ts → create-invoice/IntlLoader.d.ts} +0 -0
@@ -45,17 +45,24 @@ var api_1 = require("@unimaze/api-clients/lib/mapi/api");
45
45
  var BillingCalculations_1 = __importDefault(require("./BillingCalculations"));
46
46
  var BillingTaxSummary_1 = __importDefault(require("./BillingTaxSummary"));
47
47
  var formLayout_1 = require("../../consts/formLayout");
48
- var translationMessages = react_intl_1.defineMessages({
48
+ var editable_cell_1 = require("../editable-cell");
49
+ var IntlUtility_1 = require("../../../utils/IntlUtility");
50
+ exports.translationMessages = react_intl_1.defineMessages({
49
51
  billingLines_title: {
50
52
  id: "billingLines_title",
51
53
  defaultMessage: "Document lines",
52
54
  },
55
+ billingLines_tooltip_title: {
56
+ id: "billingLines_tooltip_title",
57
+ defaultMessage: "Here you need to define Item number, Name, Quantity, Unit of measure, Tax category and Discount.\n" + "The added value is calculated automatically.\n" +
58
+ "Click \"Add a row\" to add a product line???",
59
+ },
53
60
  billingLines_itemNo: {
54
61
  id: "billingLines_itemNo",
55
62
  defaultMessage: "Item no",
56
63
  },
57
64
  billingLines_name: {
58
- id: "billingLines_itemNo",
65
+ id: "billingLines_name",
59
66
  defaultMessage: "Name"
60
67
  },
61
68
  billingLines_quantity: {
@@ -74,6 +81,10 @@ var translationMessages = react_intl_1.defineMessages({
74
81
  id: "billingLines_taxCategoryType",
75
82
  defaultMessage: "Tax category"
76
83
  },
84
+ billingLines_taxCategoryType_title: {
85
+ id: "billingLines_taxCategoryType_title",
86
+ defaultMessage: "It is not possible to add value to a product without providing a VAT number???" // Ekki er hægt að leggja virðisauka á vöru nema gefa upp VSK númer
87
+ },
77
88
  billingLines_taxCategoryPercentage: {
78
89
  id: "billingLines_taxCategoryPercentage",
79
90
  defaultMessage: "Tax percentage"
@@ -94,92 +105,110 @@ var translationMessages = react_intl_1.defineMessages({
94
105
  id: "billingLines_button_addRow",
95
106
  defaultMessage: "Add a row"
96
107
  },
108
+ billingLines_placeholders_itemNo: {
109
+ id: "billingLines_placeholders_itemNo",
110
+ defaultMessage: "Item No"
111
+ },
112
+ billingLines_placeholders_newItem: {
113
+ id: "billingLines_placeholders_newItem",
114
+ defaultMessage: "New Item"
115
+ },
97
116
  });
98
117
  var BillingLines = /** @class */ (function (_super) {
99
118
  __extends(BillingLines, _super);
100
119
  function BillingLines(props) {
101
120
  var _this = _super.call(this, props) || this;
102
- _this.renderCurrencyColumn = function (text) {
103
- var currency = _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? _this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
104
- return text + " " + currency;
105
- };
106
121
  _this.columns = [
107
122
  {
108
- title: "Vörunr.",
123
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_itemNo),
109
124
  dataIndex: 'itemNo',
110
125
  editable: true,
126
+ width: "12em",
111
127
  },
112
128
  {
113
- title: "Nafn",
129
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_name),
114
130
  dataIndex: 'name',
115
131
  editable: true,
116
132
  },
117
133
  {
118
- title: "Fjöldi",
134
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_quantity),
119
135
  dataIndex: 'quantity',
120
136
  editable: true,
121
137
  align: "right",
122
138
  },
123
139
  {
124
- title: "Mælieining",
140
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_unitOfMeasure),
125
141
  dataIndex: 'unitOfMeasure',
142
+ align: "right",
126
143
  editable: true,
144
+ render: (function (text, record) {
145
+ return React.createElement("span", null, _this.props.intl.formatMessage(editable_cell_1.commonTranslationMessages["unitOfMeasure_labels_" + record.unitOfMeasure.value]));
146
+ })
127
147
  },
128
148
  {
129
- title: "Verð pr. einingu",
149
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_unitPriceAmount),
130
150
  dataIndex: 'unitPriceAmount',
131
151
  editable: true,
132
152
  align: "right",
153
+ render: function (text, record) {
154
+ return IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(record.unitPriceAmount ? record.unitPriceAmount : 0, props.intl);
155
+ }
156
+ // render: this.renderCurrencyColumn,
133
157
  },
134
158
  {
135
- title: (React.createElement(antd_1.Tooltip
136
- // this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType)
137
- , {
138
- // this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType)
139
- title: " Ekki er hægt að leggja virðisauka á vöru nema gefa upp VSK númer", placement: "right" },
159
+ title: (React.createElement(antd_1.Tooltip, { title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxCategoryType_title), placement: "right" },
140
160
  React.createElement("span", null,
141
- "Skattflokkur ",
161
+ _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxCategoryType),
162
+ " ",
142
163
  React.createElement(icons_1.QuestionCircleOutlined, null)))),
143
164
  dataIndex: 'taxCategoryType',
144
- editable: true,
145
- },
146
- {
147
- title: "Skattprósenta",
148
- dataIndex: 'taxCategoryPercentage',
149
- editable: false,
150
165
  align: "right",
166
+ editable: true,
151
167
  render: (function (text, record) {
152
- var taxPercentage = BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType]); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
153
- return React.createElement("span", null,
154
- taxPercentage,
155
- "%");
168
+ var taxPercentage = BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType.value]);
169
+ return React.createElement("span", null, _this.props.intl.formatMessage(editable_cell_1.commonTranslationMessages["taxCategoryType_labels_" + record.taxCategoryType.value]) + " (" + taxPercentage + "%)");
156
170
  })
157
171
  },
172
+ // {
173
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryPercentage),
174
+ // dataIndex: 'taxCategoryPercentage',
175
+ // editable: false,
176
+ // align: "right",
177
+ // render: ((text, record) => {
178
+ // const taxPercentage = calculateTaxPercentage(TaxCategoryTypeEnum[record.taxCategoryType]); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
179
+ // return <span>{taxPercentage}%</span>
180
+ // })
181
+ // },
158
182
  {
159
- title: "Afsláttur",
183
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_discount),
160
184
  dataIndex: 'discountValue',
161
185
  editable: true,
162
186
  align: "right",
187
+ width: "5em",
188
+ render: (function (text, record) {
189
+ return React.createElement("div", null, record.discountValue);
190
+ })
163
191
  },
164
192
  {
165
- title: "Upphæð",
193
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_lineAmount),
166
194
  dataIndex: 'taxableAmount',
167
195
  editable: false,
168
196
  align: "right",
169
197
  render: function (text, record) {
170
- return (React.createElement("span", null, BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount).toFixed(2)));
198
+ var taxableAmount = BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
199
+ return (React.createElement("span", null, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(taxableAmount, props.intl, { style: "decimal" })));
171
200
  }
172
201
  },
173
202
  {
174
- title: "Upphæð með skatti",
203
+ title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxAmount),
175
204
  dataIndex: 'taxInclusiveAmount',
176
205
  editable: false,
177
206
  align: "right",
178
207
  render: function (text, record) {
179
- var taxAmount = BillingLineUtility_1.calculateTaxAmount(BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount), BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType])); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
208
+ var taxAmount = BillingLineUtility_1.calculateTaxAmount(BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount), BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType.value])); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
180
209
  var taxableAmount = BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
181
210
  var taxInclusiveAmount = taxableAmount + taxAmount;
182
- return (React.createElement("span", null, taxInclusiveAmount.toFixed(2)));
211
+ return (React.createElement("span", null, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(taxInclusiveAmount, props.intl, { style: "decimal" })));
183
212
  }
184
213
  },
185
214
  {
@@ -194,6 +223,10 @@ var BillingLines = /** @class */ (function (_super) {
194
223
  ];
195
224
  return _this;
196
225
  }
226
+ // renderCurrencyColumn = (text: string | number) => {
227
+ // const currency = this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
228
+ // return text + " " + currency;
229
+ // };
197
230
  BillingLines.prototype.render = function () {
198
231
  var _this = this;
199
232
  // const dataSource = this.props.formInstance.getFieldValue(["invoice", "invoiceLines"]);
@@ -217,14 +250,12 @@ var BillingLines = /** @class */ (function (_super) {
217
250
  handleSave: function (billingLineMetadataOverrideRecord, rowIndex) { return _this.props.handleSave(billingLineMetadataOverrideRecord, _this.props.formInstance); },
218
251
  }); } });
219
252
  });
220
- var billingLinesLabelNode = (React.createElement(antd_1.Tooltip
221
- // this.props.intl.formatMessage(translationMessages.billingLines_title)
222
- , {
223
- // this.props.intl.formatMessage(translationMessages.billingLines_title)
224
- title: "Hér þarf að skilgreina Vörunr, Nafn, Fjölda, Mælieiningu, Verð pr. einingu og upphæð. Virðisauki reiknast sjálfkrafa. Smelltu á \"Bæta við röð\" til þess að bæta við vörulínu", placement: "right" },
253
+ var billingLinesLabelNode = (React.createElement(antd_1.Tooltip, { title: this.props.intl.formatMessage(exports.translationMessages.billingLines_tooltip_title), placement: "right" },
225
254
  React.createElement("span", null,
226
- "Reikningsl\u00EDnur ",
255
+ this.props.intl.formatMessage(exports.translationMessages.billingLines_title),
256
+ " ",
227
257
  React.createElement(icons_1.QuestionCircleOutlined, null))));
258
+ var currencyCode = this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
228
259
  return (React.createElement(components_1.ComponentContainer, { title: billingLinesLabelNode },
229
260
  React.createElement(antd_1.Table, {
230
261
  // style={{minHeight: "170px"}}
@@ -232,12 +263,14 @@ var BillingLines = /** @class */ (function (_super) {
232
263
  React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.fullWidthInput),
233
264
  React.createElement(antd_1.Button, { type: "dashed", onClick: function () { return _this.props.handleAdd(_this.props.initialBillingLineData); }, style: { width: "100%" } },
234
265
  React.createElement(icons_1.PlusOutlined, null),
235
- "Bæta við röð")),
266
+ this.props.intl.formatMessage(exports.translationMessages.billingLines_button_addRow))),
236
267
  React.createElement(antd_1.Row, { style: { marginTop: "1em" }, align: "top", justify: "space-between", gutter: [16, 16] },
237
268
  React.createElement(antd_1.Col, { span: 16 },
238
269
  React.createElement(BillingTaxSummary_1.default, { billingLines: dataSource })),
239
270
  React.createElement(antd_1.Col, { span: 8 },
240
- React.createElement(BillingCalculations_1.default, { billingLinesMetadata: dataSource, renderCurrencyColumn: this.renderCurrencyColumn })))));
271
+ React.createElement(BillingCalculations_1.default, { billingLinesMetadata: dataSource,
272
+ // renderCurrencyColumn={this.renderCurrencyColumn}
273
+ currencyCode: currencyCode })))));
241
274
  };
242
275
  return BillingLines;
243
276
  }(React.Component));
@@ -10,7 +10,7 @@ interface Props extends InjectedIntlProps {
10
10
  setChosenCustomer: (chosenCustomer: PartyMetadata) => void;
11
11
  setChosenCustomerApiKey: (chosenCustomerApiKey: string) => void;
12
12
  }
13
- declare const CustomerIntl: React.ComponentClass<Pick<Props, "formInstance" | "customers" | "chosenCustomer" | "setChosenCustomer" | "setChosenCustomerApiKey">, any> & {
13
+ declare const CustomerIntl: React.ComponentClass<Pick<Props, "customers" | "formInstance" | "chosenCustomer" | "setChosenCustomer" | "setChosenCustomerApiKey">, any> & {
14
14
  WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
15
15
  };
16
16
  export default CustomerIntl;
@@ -74,20 +74,14 @@ var Customer = function (props) {
74
74
  props.setChosenCustomerApiKey(props.customers[customerIndex].apiKey);
75
75
  props.formInstance.setFieldsValue(newFormValues);
76
76
  };
77
- return (
78
- // props.intl.formatMessage(translationMessages.customer_title)
79
- react_1.default.createElement(components_1.ComponentContainer, { title: "Viðskiptavinur" },
80
- react_1.default.createElement(form_item_1.default
81
- // defaultLabel={"Select the customer"}
82
- , {
83
- // defaultLabel={"Select the customer"}
84
- defaultLabel: "Veldu viðskiptavin", defaultIsRequired: true, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.identifier"], fieldName: ["invoice", "customer", "name"] },
77
+ return (react_1.default.createElement(components_1.ComponentContainer, { title: props.intl.formatMessage(translationMessages.customer_title) },
78
+ react_1.default.createElement(form_item_1.default, { defaultLabel: props.intl.formatMessage(translationMessages.customer_selectTheCustomer), defaultIsRequired: true, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.identifier"], fieldName: ["invoice", "customer", "name"] },
85
79
  react_1.default.createElement(antd_1.Select, { onChange: function (value) {
86
80
  onCustomerChange(value);
87
81
  } }, props.customers.map(function (customer, index) { return (react_1.default.createElement(antd_1.Select.Option, { key: index, value: index }, customer.name)); }))),
88
- react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: "Nafn" }), chosenCustomer && chosenCustomer.name),
89
- react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: "Kennitala" }), chosenCustomer && ConversionUtility_1.convertToReadableKennitala(chosenCustomer.identifier)),
90
- react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: "Heimilisfang" }), chosenCustomer && chosenCustomer.address
82
+ react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_name), style: { display: "none" } }), chosenCustomer && chosenCustomer.name),
83
+ react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_identifier) }), chosenCustomer && ConversionUtility_1.convertToReadableKennitala(chosenCustomer.identifier)),
84
+ react_1.default.createElement(antd_1.Form.Item, __assign({}, formLayout_1.formItemLayout, { label: props.intl.formatMessage(translationMessages.customer_address_streetNameAndNumber) }), chosenCustomer && chosenCustomer.address
91
85
  ? react_1.default.createElement(react_1.default.Fragment, null,
92
86
  chosenCustomer.address.streetNameAndNumber,
93
87
  react_1.default.createElement("br", null),
@@ -1,11 +1,15 @@
1
1
  import React from "react";
2
2
  import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
3
- interface EditableCellProps {
3
+ import { InjectedIntlProps } from "react-intl";
4
+ export declare const commonTranslationMessages: ReactIntl.Messages<"taxCategoryType_labels_StandardRated" | "taxCategoryType_labels_ReducedRated" | "taxCategoryType_labels_ZeroRated" | "taxCategoryType_labels_Exempt" | "unitOfMeasure_labels_Piece" | "unitOfMeasure_labels_Kilogram" | "unitOfMeasure_labels_Month" | "unitOfMeasure_labels_Package" | "unitOfMeasure_labels_Year" | "unitOfMeasure_labels_Day" | "unitOfMeasure_labels_Hour" | "unitOfMeasure_labels_Kilometre" | "unitOfMeasure_labels_Metre" | "unitOfMeasure_labels_Litre" | "unitOfMeasure_labels_SquareMetre" | "unitOfMeasure_labels_CubicMetre" | "unitOfMeasure_labels_Tonne" | "unitOfMeasure_labels_KiloWattHour" | "unitOfMeasure_labels_One">;
5
+ interface EditableCellProps extends InjectedIntlProps {
4
6
  record: BillingLineMetadataOverride;
5
7
  handleSave: (billingLineMetadata: BillingLineMetadataOverride) => void;
6
8
  dataIndex: keyof Omit<BillingLineMetadataOverride, 'key'>;
7
9
  editable: boolean;
8
10
  index: number;
9
11
  }
10
- declare const EditableCell: React.FC<EditableCellProps>;
11
- export default EditableCell;
12
+ declare const EditableCellIntl: React.ComponentClass<Pick<EditableCellProps, "dataIndex" | "editable" | "index" | "record" | "handleSave">, any> & {
13
+ WrappedComponent: React.ComponentType<EditableCellProps & InjectedIntlProps>;
14
+ };
15
+ export default EditableCellIntl;
@@ -70,6 +70,114 @@ var antd_1 = require("antd");
70
70
  var models_1 = require("@unimaze/api-clients/lib/mapi/models");
71
71
  var validationRules_1 = require("../../consts/validationRules");
72
72
  var editable_row_1 = require("../editable-row");
73
+ var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
74
+ var api_1 = require("@unimaze/api-clients/lib/mapi/api");
75
+ var react_intl_1 = require("react-intl");
76
+ var IntlUtility_1 = require("../../../utils/IntlUtility");
77
+ exports.commonTranslationMessages = react_intl_1.defineMessages({
78
+ taxCategoryType_labels_StandardRated: {
79
+ id: "taxCategoryType_labels_StandardRated",
80
+ defaultMessage: "Standard rated",
81
+ },
82
+ taxCategoryType_labels_ReducedRated: {
83
+ id: "taxCategoryType_labels_ReducedRated",
84
+ defaultMessage: "Reduced rated",
85
+ },
86
+ taxCategoryType_labels_ZeroRated: {
87
+ id: "taxCategoryType_labels_ZeroRated",
88
+ defaultMessage: "Zero rated",
89
+ },
90
+ taxCategoryType_labels_Exempt: {
91
+ id: "taxCategoryType_labels_Exempt",
92
+ defaultMessage: "Exempt",
93
+ },
94
+ unitOfMeasure_labels_Piece: {
95
+ id: "unitOfMeasure_labels_Piece",
96
+ defaultMessage: "Piece",
97
+ },
98
+ unitOfMeasure_labels_Kilogram: {
99
+ id: "unitOfMeasure_labels_Kilogram",
100
+ defaultMessage: "Kilogram",
101
+ },
102
+ unitOfMeasure_labels_Month: {
103
+ id: "unitOfMeasure_labels_Month",
104
+ defaultMessage: "Month",
105
+ },
106
+ unitOfMeasure_labels_Package: {
107
+ id: "unitOfMeasure_labels_Package",
108
+ defaultMessage: "Package",
109
+ },
110
+ unitOfMeasure_labels_Year: {
111
+ id: "unitOfMeasure_labels_Year",
112
+ defaultMessage: "Year",
113
+ },
114
+ unitOfMeasure_labels_Day: {
115
+ id: "unitOfMeasure_labels_Day",
116
+ defaultMessage: "Day",
117
+ },
118
+ unitOfMeasure_labels_Hour: {
119
+ id: "unitOfMeasure_labels_Hour",
120
+ defaultMessage: "Hour",
121
+ },
122
+ unitOfMeasure_labels_Kilometre: {
123
+ id: "unitOfMeasure_labels_Kilometre",
124
+ defaultMessage: "Kilometre",
125
+ },
126
+ unitOfMeasure_labels_Metre: {
127
+ id: "unitOfMeasure_labels_Metre",
128
+ defaultMessage: "Metre",
129
+ },
130
+ unitOfMeasure_labels_Litre: {
131
+ id: "unitOfMeasure_labels_Litre",
132
+ defaultMessage: "Litre",
133
+ },
134
+ unitOfMeasure_labels_SquareMetre: {
135
+ id: "unitOfMeasure_labels_SquareMetre",
136
+ defaultMessage: "Square metre",
137
+ },
138
+ unitOfMeasure_labels_CubicMetre: {
139
+ id: "unitOfMeasure_labels_CubicMetre",
140
+ defaultMessage: "Cubic metre",
141
+ },
142
+ unitOfMeasure_labels_Tonne: {
143
+ id: "unitOfMeasure_labels_Tonne",
144
+ defaultMessage: "Tonne",
145
+ },
146
+ unitOfMeasure_labels_KiloWattHour: {
147
+ id: "unitOfMeasure_labels_KiloWattHour",
148
+ defaultMessage: "KiloWatt hour",
149
+ },
150
+ unitOfMeasure_labels_One: {
151
+ id: "unitOfMeasure_labels_One",
152
+ defaultMessage: "One",
153
+ },
154
+ });
155
+ var validationTranslationMessages = react_intl_1.defineMessages({
156
+ rulesMessages_name_required: {
157
+ id: "rulesMessages_name_required",
158
+ defaultMessage: "Please insert item name",
159
+ },
160
+ rulesMessages_unitOfMeasure_required: {
161
+ id: "rulesMessages_unitOfMeasure_required",
162
+ defaultMessage: "Please choose unit of measure",
163
+ },
164
+ rulesMessages_unitPriceAmount_required: {
165
+ id: "rulesMessages_unitPriceAmount_required",
166
+ defaultMessage: "Please fill in unit price amount",
167
+ },
168
+ rulesMessages_unitPriceAmount_type: {
169
+ id: "rulesMessages_unitPriceAmount_type",
170
+ defaultMessage: "Unit price amount must be a number",
171
+ },
172
+ rulesMessages_taxCategoryType_required: {
173
+ id: "rulesMessages_taxCategoryType_required",
174
+ defaultMessage: "Please choose tax category type",
175
+ },
176
+ rulesMessages_discountValue_pattern: {
177
+ id: "rulesMessages_discountValue_pattern",
178
+ defaultMessage: "Please use only numbers characters and percentage character at the end",
179
+ },
180
+ });
73
181
  var EditableCell = function (props) {
74
182
  var editable = props.editable, dataIndex = props.dataIndex,
75
183
  // title,
@@ -96,6 +204,9 @@ var EditableCell = function (props) {
96
204
  return [3 /*break*/, 3];
97
205
  case 2:
98
206
  errInfo_1 = _a.sent();
207
+ // tslint:disable-next-line:no-console
208
+ console.log('Save failed:', errInfo_1);
209
+ antd_1.message.error(errInfo_1);
99
210
  return [3 /*break*/, 3];
100
211
  case 3: return [2 /*return*/];
101
212
  }
@@ -105,24 +216,30 @@ var EditableCell = function (props) {
105
216
  switch (dataIdx) {
106
217
  case "quantity":
107
218
  case "unitPriceAmount":
108
- return react_1.default.createElement(antd_1.InputNumber, { step: 1,
219
+ return react_1.default.createElement(antd_1.InputNumber, { step: 1, decimalSeparator: IntlUtility_1.returnDecimalSeparatorForLocale(localStorage.getItem("languageString")),
109
220
  // ref={node => (input = node)}
110
221
  // onPressEnter={save}
111
222
  onBlur: save });
112
223
  case "discountValue":
113
224
  return react_1.default.createElement(antd_1.Input, { onBlur: save });
114
225
  case "unitOfMeasure":
115
- return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
226
+ return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); },
227
+ // defaultActiveFirstOption
116
228
  // onSelect={save}
117
- onChange: save }, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
229
+ labelInValue: true, onChange: save }, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
118
230
  if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
119
- return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, unitOfMeasure));
231
+ return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure,
232
+ // title={unitOfMeasure}
233
+ key: unitOfMeasure }, props.intl.formatMessage(exports.commonTranslationMessages["unitOfMeasure_labels_" + unitOfMeasure])));
120
234
  })));
121
235
  case "taxCategoryType":
122
- return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
236
+ return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); },
237
+ // defaultActiveFirstOption
238
+ labelInValue: true,
123
239
  // onSelect={save}
124
240
  onChange: save }, Object.keys(models_1.BillingLineMetadataTaxCategoryTypeEnum).map(function (taxCategoryType) {
125
- return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
241
+ var taxPercentage = BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[taxCategoryType]);
242
+ return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, key: taxCategoryType }, props.intl.formatMessage(exports.commonTranslationMessages["taxCategoryType_labels_" + taxCategoryType]) + " (" + taxPercentage + "%)"));
126
243
  })));
127
244
  default:
128
245
  return react_1.default.createElement(antd_1.Input, { ref: function (node) { return (input = node); },
@@ -133,7 +250,12 @@ var EditableCell = function (props) {
133
250
  var renderCell = function () {
134
251
  var inputNode = getCorrectInputNode(dataIndex);
135
252
  var rules = validationRules_1.validationRules[dataIndex];
136
- 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));
253
+ var translatableRules = rules && rules.map(function (singleRule) {
254
+ return __assign({}, singleRule, { message: singleRule.message && props.intl.formatMessage(validationTranslationMessages["rulesMessages_" + singleRule.message]) });
255
+ });
256
+ return editing ? (react_1.default.createElement(antd_1.Form.Item, { style: { margin: 0 }, rules: translatableRules, name: dataIndex, initialValue: record[dataIndex] }, inputNode)) : (react_1.default.createElement("div", { className: "editable-cell-value-wrap",
257
+ // style={{paddingRight: 24}}
258
+ onClick: toggleEdit }, children));
137
259
  // return (
138
260
  // <Form.Item
139
261
  // style={{margin: 0}}
@@ -147,4 +269,5 @@ var EditableCell = function (props) {
147
269
  };
148
270
  return (react_1.default.createElement("td", __assign({}, restProps), editable ? (react_1.default.createElement(editable_row_1.EditableContext.Consumer, null, renderCell)) : (children)));
149
271
  };
150
- exports.default = EditableCell;
272
+ var EditableCellIntl = react_intl_1.injectIntl(EditableCell);
273
+ exports.default = EditableCellIntl;
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { AvailableFields } from "../../types/ReceiverRequirements";
3
3
  import { NamePath, Rule } from "rc-field-form/lib/interface";
4
4
  import { InjectedIntlProps } from "react-intl";
5
+ import { FormItemProps } from "antd/lib/form/FormItem";
5
6
  interface StringMap {
6
7
  [key: string]: string;
7
8
  }
8
- interface Props extends InjectedIntlProps {
9
+ interface Props extends InjectedIntlProps, FormItemProps {
9
10
  receiverRequirementsKey: AvailableFields;
10
11
  defaultLabel: React.ReactNode;
12
+ defaultLabelTooltip?: React.ReactNode;
11
13
  defaultIsRequired: boolean;
12
14
  fieldName: NamePath;
13
15
  additionalRules?: Rule[];
@@ -17,7 +19,7 @@ interface Props extends InjectedIntlProps {
17
19
  onlyLabelOnFirstInList?: boolean;
18
20
  index?: number;
19
21
  }
20
- declare const _default: React.ComponentClass<Pick<Props, "style" | "initialValue" | "index" | "fieldName" | "receiverRequirementsKey" | "defaultLabel" | "defaultIsRequired" | "additionalRules" | "verticalLabels" | "onlyLabelOnFirstInList">, any> & {
22
+ declare const _default: React.ComponentClass<Pick<Props, "normalize" | "required" | "label" | "style" | "help" | "children" | "name" | "validateTrigger" | "dependencies" | "getValueFromEvent" | "rules" | "shouldUpdate" | "trigger" | "validateFirst" | "valuePropName" | "getValueProps" | "messageVariables" | "initialValue" | "onReset" | "className" | "id" | "prefixCls" | "isListField" | "colon" | "extra" | "htmlFor" | "index" | "fieldName" | "receiverRequirementsKey" | "defaultLabel" | "defaultLabelTooltip" | "defaultIsRequired" | "additionalRules" | "verticalLabels" | "onlyLabelOnFirstInList" | "noStyle" | "hasFeedback" | "validateStatus" | "fieldKey" | "labelAlign" | "labelCol" | "wrapperCol">, any> & {
21
23
  WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
22
24
  };
23
25
  export default _default;
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
13
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
@@ -20,6 +31,7 @@ var antd_1 = require("antd");
20
31
  var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
21
32
  var react_intl_1 = require("react-intl");
22
33
  var formLayout_1 = require("../../consts/formLayout");
34
+ var icons_1 = require("@ant-design/icons");
23
35
  var translationMessages = react_intl_1.defineMessages({
24
36
  formItem_required_errorMessage: {
25
37
  id: "formItem_required_errorMessage",
@@ -27,18 +39,26 @@ var translationMessages = react_intl_1.defineMessages({
27
39
  },
28
40
  });
29
41
  var UmzFormItem = function (props) {
30
- var label = RequirementsUtility_1.getReceiverRequirementsLabelWithDefault(ReceiverRequirements_1.receiverRequirementsObject, props.receiverRequirementsKey, props.defaultLabel);
31
- var isRequired = RequirementsUtility_1.getReceiverRequirementsIsRequired(ReceiverRequirements_1.receiverRequirementsObject, props.receiverRequirementsKey, props.defaultIsRequired);
32
- return (react_1.default.createElement(antd_1.Form.Item, __assign({}, props.verticalLabels ? formLayout_1.formItemVerticalLayout : formLayout_1.formItemLayout, { label: props.onlyLabelOnFirstInList
33
- ? props.index === 0
42
+ var children = props.children, onlyLabelOnFirstInList = props.onlyLabelOnFirstInList, index = props.index, defaultLabel = props.defaultLabel, defaultIsRequired = props.defaultIsRequired, initialValue = props.initialValue, additionalRules = props.additionalRules, verticalLabels = props.verticalLabels, fieldName = props.fieldName, receiverRequirementsKey = props.receiverRequirementsKey, style = props.style, defaultLabelTooltip = props.defaultLabelTooltip, rest = __rest(props, ["children", "onlyLabelOnFirstInList", "index", "defaultLabel", "defaultIsRequired", "initialValue", "additionalRules", "verticalLabels", "fieldName", "receiverRequirementsKey", "style", "defaultLabelTooltip"]);
43
+ var labelString = RequirementsUtility_1.getReceiverRequirementsLabelWithDefault(ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey, defaultLabel);
44
+ var label = defaultLabelTooltip
45
+ ? react_1.default.createElement(antd_1.Tooltip, { title: defaultLabelTooltip, placement: "right" },
46
+ react_1.default.createElement("span", null,
47
+ labelString,
48
+ " ",
49
+ react_1.default.createElement(icons_1.QuestionCircleOutlined, null)))
50
+ : labelString;
51
+ var isRequired = RequirementsUtility_1.getReceiverRequirementsIsRequired(ReceiverRequirements_1.receiverRequirementsObject, receiverRequirementsKey, defaultIsRequired);
52
+ return (react_1.default.createElement(antd_1.Form.Item, __assign({}, verticalLabels ? formLayout_1.formItemVerticalLayout : formLayout_1.formItemLayout, { label: onlyLabelOnFirstInList
53
+ ? index === 0
34
54
  ? label
35
55
  : null
36
- : label, name: props.fieldName, rules: [
56
+ : label, name: fieldName, rules: [
37
57
  {
38
58
  required: isRequired,
39
59
  message: "Það þarf að fylla út í þennan reit",
40
60
  }
41
- ].concat((props.additionalRules || []) // if the array is undefined
42
- ), style: props.style, initialValue: props.initialValue }), props.children));
61
+ ].concat((additionalRules || []) // if the array is undefined
62
+ ), style: style, initialValue: initialValue }, rest), children));
43
63
  };
44
64
  exports.default = react_intl_1.injectIntl(UmzFormItem);