@unimaze/billing 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,8 +21,8 @@ A form for creating an invoice and submitting it to the MAPI transaction service
21
21
 
22
22
  ## Updating the version ##
23
23
  - `yarn version --major` - updates the major version number 1.x.x
24
- - `yarn version --minor` - updates the major version number x.1.x
25
- - `yarn version --patch` - updates the major version number x.x.1
24
+ - `yarn version --minor` - updates the minor version number x.1.x
25
+ - `yarn version --patch` - updates the patch version number x.x.1
26
26
 
27
27
  Make sure you have a remote branch already on BitBucket before running the version command.
28
28
  Make sure that you update the version number in the `standalone-billing` repository that consumes this package
@@ -163,6 +163,14 @@ var AttachmentModal = function (props) {
163
163
  },
164
164
  fileList: props.attachments.map(function (attachment) { return attachment.file; }),
165
165
  disabled: isUploading || props.attachments.length >= 3,
166
+ customRequest: function (_a) {
167
+ var onSuccess = _a.onSuccess;
168
+ if (onSuccess) {
169
+ setTimeout(function () {
170
+ onSuccess("ok");
171
+ }, 0);
172
+ }
173
+ }
166
174
  };
167
175
  return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel: function () { return props.setIsModalOpen(false); }, title: props.intl.formatMessage(translationMessages.attachment_title), footer: React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: function () {
168
176
  props.onSave();
@@ -74,7 +74,7 @@ var BillingCalculations = function (props) {
74
74
  var taxAmount = (0, BillingLineUtility_1.calculateTaxAmount)((0, BillingLineUtility_1.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType), (0, BillingLineUtility_1.calculateTaxPercentage)(billingLine.taxCategoryType ? api_1.TaxCategoryTypeEnum[billingLine.taxCategoryType] : undefined));
75
75
  var taxableAmount = (0, BillingLineUtility_1.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
76
76
  var taxInclusiveAmount = taxableAmount + taxAmount;
77
- var discountAmount = (0, BillingLineUtility_1.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
77
+ var discountAmount = billingLine.discountType === "PERCENTAGE" ? (0, BillingLineUtility_1.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount) : billingLine.discountValue ? parseFloat(billingLine.discountValue) : 0;
78
78
  totals = {
79
79
  totalTaxAmount: totals.totalTaxAmount + taxAmount,
80
80
  totalTaxableAmount: totals.totalTaxableAmount + taxableAmount,
@@ -90,6 +90,8 @@ var BillingCalculations = function (props) {
90
90
  if (totals.totalTaxableAmount <= 0 || totals.totalTaxInclusiveAmount <= 0) {
91
91
  return null;
92
92
  }
93
+ var roundedAmount = Math.round(totals.totalTaxInclusiveAmount);
94
+ var roundingAmount = totals.totalTaxInclusiveAmount - roundedAmount;
93
95
  return (react_1.default.createElement(antd_1.Flex, { vertical: true },
94
96
  react_1.default.createElement(antd_1.Flex, { justify: "end", gap: 'large' },
95
97
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: { fontWeight: 300 } },
@@ -101,6 +103,9 @@ var BillingCalculations = function (props) {
101
103
  ":"),
102
104
  totals.discountAmount > 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
103
105
  props.intl.formatMessage(translationMessages.billingLines_discount),
106
+ ":")),
107
+ roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
108
+ props.intl.formatMessage(translationMessages.billingCalculations_labels_RoundingAmount),
104
109
  ":"))),
105
110
  react_1.default.createElement(antd_1.Flex, { vertical: true },
106
111
  react_1.default.createElement(antd_1.Typography.Text, { strong: true },
@@ -120,6 +125,12 @@ var BillingCalculations = function (props) {
120
125
  style: "decimal",
121
126
  }),
122
127
  " ",
128
+ props.formInstance.getFieldValue(["invoice", "currencyCode"]))),
129
+ roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, { strong: true },
130
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundingAmount, props.intl, {
131
+ style: "decimal",
132
+ }),
133
+ " ",
123
134
  props.formInstance.getFieldValue(["invoice", "currencyCode"]))))),
124
135
  react_1.default.createElement(antd_1.Row, null,
125
136
  react_1.default.createElement(antd_1.Col, { span: 24 },
@@ -129,7 +140,7 @@ var BillingCalculations = function (props) {
129
140
  " ",
130
141
  "=",
131
142
  " ",
132
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(Math.round(totals.totalTaxInclusiveAmount), props.intl, {
143
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundedAmount, props.intl, {
133
144
  style: "decimal",
134
145
  }),
135
146
  " ",
@@ -72,6 +72,10 @@ var translationMessages = (0, react_intl_1.defineMessages)({
72
72
  id: "billingCalculations_labels_TotalAmountWithVat",
73
73
  defaultMessage: "Total amount with VAT",
74
74
  },
75
+ billingCalculations_labels_TotalRoundingAmount: {
76
+ id: "billingCalculations_labels_TotalRoundingAmount",
77
+ defaultMessage: "Rounding amount",
78
+ },
75
79
  billingLines_discount: {
76
80
  id: "billingLines_discount",
77
81
  defaultMessage: "Discount",
@@ -131,6 +135,7 @@ var InvoicePreview = function (props) {
131
135
  var formValueFile1 = props.form.getFieldValue(["attachments", "file1", "file"]);
132
136
  var formValueFile2 = props.form.getFieldValue(["attachments", "file2", "file"]);
133
137
  var formValueFile3 = props.form.getFieldValue(["attachments", "file3", "file"]);
138
+ var _totals = (0, BillingLineUtility_1.getTotals)(props.form.getFieldValue(["invoice", "invoiceLines"]));
134
139
  return (react_1.default.createElement(antd_1.Flex, { justify: "center" },
135
140
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: { width: "100%", maxWidth: "900px" } },
136
141
  react_1.default.createElement(antd_1.Row, { gutter: [20, 20] },
@@ -212,6 +217,9 @@ var InvoicePreview = function (props) {
212
217
  .map(function (line, index) {
213
218
  var _a, _b;
214
219
  var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[line.taxCategoryType]);
220
+ var calculatedDiscountValue = line.discountType === "PERCENTAGE"
221
+ ? (0, BillingLineUtility_1.calculateDiscountAmount)(line.discountValue, line.quantity, line.unitPriceAmount)
222
+ : line.discountValue;
215
223
  return (react_1.default.createElement(antd_1.Flex, { key: index, vertical: true, gap: "small" },
216
224
  react_1.default.createElement(antd_1.Flex, { vertical: true },
217
225
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, line.name),
@@ -240,13 +248,11 @@ var InvoicePreview = function (props) {
240
248
  " ",
241
249
  line.currencyCode)),
242
250
  line.discountValue && (react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center" },
243
- react_1.default.createElement(antd_1.Typography.Text, null,
244
- line.discountValue,
245
- "%",
251
+ react_1.default.createElement(antd_1.Typography.Text, null, "".concat(line.discountValue).concat(line.discountType === "PERCENTAGE" ? "%" : " ".concat(line.currencyCode)),
246
252
  " ",
247
253
  props.intl.formatMessage(translationMessages.billingLines_discount)),
248
254
  react_1.default.createElement(antd_1.Typography.Text, null,
249
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.calculateDiscountAmount)(line.discountValue, line.quantity, line.unitPriceAmount), props.intl),
255
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(calculatedDiscountValue, props.intl),
250
256
  " ",
251
257
  line.currencyCode))),
252
258
  react_1.default.createElement(antd_1.Flex, { vertical: true },
@@ -268,15 +274,22 @@ var InvoicePreview = function (props) {
268
274
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
269
275
  props.form.getFieldValue(["invoice", "currencyCode"]),
270
276
  " ",
271
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.getTotals)(props.form.getFieldValue(["invoice", "invoiceLines"]))
277
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
272
278
  .totalTaxableAmount, props.intl)))),
273
279
  react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
274
280
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalAmountWithVat)),
275
281
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
276
282
  props.form.getFieldValue(["invoice", "currencyCode"]),
277
283
  " ",
278
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.getTotals)(props.form.getFieldValue(["invoice", "invoiceLines"]))
279
- .totalTaxInclusiveAmount, props.intl)))))),
284
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
285
+ .totalTaxInclusiveAmount, props.intl)))),
286
+ react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
287
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalRoundingAmount)),
288
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
289
+ props.form.getFieldValue(["invoice", "currencyCode"]),
290
+ " ",
291
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
292
+ .roundingAmount, props.intl)))))),
280
293
  react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center", style: { padding: "0 24px" } },
281
294
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } },
282
295
  props.intl.formatMessage(translationMessages.billingCalculations_labels_AmountPayable),
@@ -284,8 +297,7 @@ var InvoicePreview = function (props) {
284
297
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } },
285
298
  props.form.getFieldValue(["invoice", "currencyCode"]),
286
299
  " ",
287
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeXL } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.getTotals)(props.form.getFieldValue(["invoice", "invoiceLines"]))
288
- .totalTaxInclusiveAmount, props.intl)))))),
300
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeXL } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(Math.round(_totals.totalTaxInclusiveAmount), props.intl)))))),
289
301
  props.form.getFieldValue(["invoice", "notes"]) && (react_1.default.createElement(antd_1.Col, { span: 24 },
290
302
  react_1.default.createElement(antd_1.Card, { bordered: false, size: "small", style: { backgroundColor: "#F5F5F5" } },
291
303
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 12px" } },
@@ -67,6 +67,10 @@ export declare const translationMessages: {
67
67
  id: string;
68
68
  defaultMessage: string;
69
69
  };
70
+ supplier_notFound: {
71
+ id: string;
72
+ defaultMessage: string;
73
+ };
70
74
  };
71
75
  interface Props extends WrappedComponentProps {
72
76
  receiverRequirements: NewReceiverRequirements;
@@ -117,6 +117,10 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
117
117
  id: "supplier_vatNumber_mandatory",
118
118
  defaultMessage: "VAT number is required if some document lines are using any tax category type other than 'Outside tax scope'",
119
119
  },
120
+ supplier_notFound: {
121
+ id: "supplier_notFound",
122
+ defaultMessage: "Did not find information about name and address of party from entered identifier",
123
+ },
120
124
  });
121
125
  var Supplier = function (props) {
122
126
  var width = (0, react_use_1.useWindowSize)().width;
@@ -190,7 +194,7 @@ var Supplier = function (props) {
190
194
  // The request was made and the server responded with a status code
191
195
  // that falls out of the range of 2xx
192
196
  if (error.response.status === 404) {
193
- antd_1.message.warning("Fann ekki uppl\u00FDsingar um nafn og heimilisfang a\u00F0ila \u00FAt fr\u00E1 innsleginni kennit\u00F6lu");
197
+ antd_1.message.warning(props.intl.formatMessage(exports.translationMessages.supplier_notFound));
194
198
  }
195
199
  else {
196
200
  antd_1.message.error(error.response.statusText);
@@ -34,6 +34,7 @@
34
34
  "billingCalculations_labels_RoundingAmount": "Rounding amount",
35
35
  "billingCalculations_labels_TaxAmountWithoutVat": "Total amount without VAT",
36
36
  "billingCalculations_labels_TotalAmountWithVat": "Total amount with VAT",
37
+ "billingCalculations_labels_TotalRoundingAmount": "Rounding amount",
37
38
  "billingCalculations_labels_TotalVatAmount": "Total VAT amount",
38
39
  "billingLines_button_addRow": "Add a row",
39
40
  "billingLines_currencyCode": "Currency",
@@ -148,6 +149,7 @@
148
149
  "supplier_contact_phoneNumber": "Phone number",
149
150
  "supplier_identifier": "Supplier identifier",
150
151
  "supplier_name": "Supplier name",
152
+ "supplier_notFound": "Did not find information about name and address of party from entered identifier",
151
153
  "supplier_notValidEmail": "This is not a valid E-Mail",
152
154
  "supplier_notVatRegistered": "Not VAT registered",
153
155
  "supplier_title": "Supplier",
@@ -34,6 +34,7 @@
34
34
  "billingCalculations_labels_RoundingAmount": "Afrúningur aura",
35
35
  "billingCalculations_labels_TaxAmountWithoutVat": "Samtals án VSK",
36
36
  "billingCalculations_labels_TotalAmountWithVat": "Samtals með VSK",
37
+ "billingCalculations_labels_TotalRoundingAmount": "Afrúningur aura",
37
38
  "billingCalculations_labels_TotalVatAmount": "Samtals VSK upphæð",
38
39
  "billingLines_button_addRow": "Bæta við röð",
39
40
  "billingLines_currencyCode": "Currency",
@@ -148,6 +149,7 @@
148
149
  "supplier_contact_phoneNumber": "Símanúmer",
149
150
  "supplier_identifier": "Kennitala",
150
151
  "supplier_name": "Nafn birgja",
152
+ "supplier_notFound": "Fann ekki upplýsingar um nafn og heimilisfang aðila út frá innsleginni kennitölu",
151
153
  "supplier_notValidEmail": "Þetta er ekki gilt netfang",
152
154
  "supplier_notVatRegistered": "Ekki VSK skyldur rekstur",
153
155
  "supplier_title": "Birgi",
@@ -35,6 +35,7 @@ declare const _default: {
35
35
  billingCalculations_labels_RoundingAmount: string;
36
36
  billingCalculations_labels_TaxAmountWithoutVat: string;
37
37
  billingCalculations_labels_TotalAmountWithVat: string;
38
+ billingCalculations_labels_TotalRoundingAmount: string;
38
39
  billingCalculations_labels_TotalVatAmount: string;
39
40
  billingLines_button_addRow: string;
40
41
  billingLines_currencyCode: string;
@@ -149,6 +150,7 @@ declare const _default: {
149
150
  supplier_contact_phoneNumber: string;
150
151
  supplier_identifier: string;
151
152
  supplier_name: string;
153
+ supplier_notFound: string;
152
154
  supplier_notValidEmail: string;
153
155
  supplier_notVatRegistered: string;
154
156
  supplier_title: string;
@@ -216,6 +218,7 @@ declare const _default: {
216
218
  billingCalculations_labels_RoundingAmount: string;
217
219
  billingCalculations_labels_TaxAmountWithoutVat: string;
218
220
  billingCalculations_labels_TotalAmountWithVat: string;
221
+ billingCalculations_labels_TotalRoundingAmount: string;
219
222
  billingCalculations_labels_TotalVatAmount: string;
220
223
  billingLines_button_addRow: string;
221
224
  billingLines_currencyCode: string;
@@ -330,6 +333,7 @@ declare const _default: {
330
333
  supplier_contact_phoneNumber: string;
331
334
  supplier_identifier: string;
332
335
  supplier_name: string;
336
+ supplier_notFound: string;
333
337
  supplier_notValidEmail: string;
334
338
  supplier_notVatRegistered: string;
335
339
  supplier_title: string;
@@ -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
  };
@@ -24,10 +35,11 @@ var billingLinesFieldsMetadata = function (formInstance) {
24
35
  var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
25
36
  return billingLinesMetadata.map(function (billingLine) {
26
37
  var cleanBillingLine = (0, ConversionUtility_1.removeEmpty)(billingLine);
27
- var taxableAmount = (0, exports.calculateTaxableAmount)(cleanBillingLine.discountValue, cleanBillingLine.quantity, cleanBillingLine.unitPriceAmount, cleanBillingLine.discountType);
28
- var taxPercentage = (0, exports.calculateTaxPercentage)(cleanBillingLine.taxCategoryType);
38
+ var discountType = cleanBillingLine.discountType, restBillingLines = __rest(cleanBillingLine, ["discountType"]); // NBNB: removing the added discountType from the properties that will be added to the mappedBillingLine
39
+ var taxableAmount = (0, exports.calculateTaxableAmount)(restBillingLines.discountValue, restBillingLines.quantity, restBillingLines.unitPriceAmount, discountType);
40
+ var taxPercentage = (0, exports.calculateTaxPercentage)(restBillingLines.taxCategoryType);
29
41
  var taxAmount = (0, exports.calculateTaxAmount)(taxableAmount, taxPercentage);
30
- var mappedBillingLine = __assign(__assign({}, cleanBillingLine), { taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
42
+ var mappedBillingLine = __assign(__assign({}, restBillingLines), { discountValue: discountType === "PERCENTAGE" ? "".concat(restBillingLines.discountValue, "%") : restBillingLines.discountValue, taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
31
43
  if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
32
44
  delete mappedBillingLine.discountValue;
33
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",