@molopos/shared 2.0.27 → 2.0.29
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/enum/index.d.ts +7 -6
- package/enum/index.js +6 -5
- package/lib/utils/index.js +7 -5
- package/package.json +1 -1
package/enum/index.d.ts
CHANGED
|
@@ -36,12 +36,14 @@ export declare enum ProductTypeEnum {
|
|
|
36
36
|
* Query type enum
|
|
37
37
|
*/
|
|
38
38
|
export declare enum QueryTypeEnum {
|
|
39
|
+
Task = "TASK",
|
|
39
40
|
Unit = "UNIT",
|
|
40
41
|
Post = "POST",
|
|
41
42
|
Shop = "SHOP",
|
|
42
43
|
Brand = "BRAND",
|
|
43
44
|
Order = "ORDER",
|
|
44
45
|
Quote = "QUOTE",
|
|
46
|
+
Section = "SECTION",
|
|
45
47
|
Message = "MESSAGE",
|
|
46
48
|
Catalog = "CATALOG",
|
|
47
49
|
Product = "PRODUCT",
|
|
@@ -50,22 +52,21 @@ export declare enum QueryTypeEnum {
|
|
|
50
52
|
Expense = "EXPENSE",
|
|
51
53
|
Profile = "PROFILE",
|
|
52
54
|
Variant = "VARIANT",
|
|
55
|
+
Project = "PROJECT",
|
|
56
|
+
Pipeline = "PIPELINE",
|
|
57
|
+
Customer = "CUSTOMER",
|
|
53
58
|
Checkout = "CHECKOUT",
|
|
54
59
|
Category = "CATEGORY",
|
|
60
|
+
Discount = "DISCOUNT",
|
|
55
61
|
Warehouse = "WAREHOUSE",
|
|
56
62
|
OrderItem = "ORDERITEM",
|
|
57
63
|
QuoteItem = "QUOTEITEM",
|
|
58
64
|
QuoteOption = "QUOTEOPTION",
|
|
59
|
-
Section = "SECTION",
|
|
60
|
-
Discount = "DISCOUNT",
|
|
61
|
-
Project = "PROJECT",
|
|
62
65
|
UserAddress = "USERADDRESS",
|
|
63
66
|
Subcategory = "SUBCATEGORY",
|
|
64
67
|
ExpenseItem = "EXPENSEITEM",
|
|
65
68
|
Organization = "ORGANIZATION",
|
|
66
|
-
ApplicationSection = "APPLICATIONSECTION"
|
|
67
|
-
Task = "TASK",
|
|
68
|
-
Pipeline = "PIPELINE"
|
|
69
|
+
ApplicationSection = "APPLICATIONSECTION"
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* Activity model enum
|
package/enum/index.js
CHANGED
|
@@ -44,12 +44,14 @@ var ProductTypeEnum;
|
|
|
44
44
|
*/
|
|
45
45
|
var QueryTypeEnum;
|
|
46
46
|
(function (QueryTypeEnum) {
|
|
47
|
+
QueryTypeEnum["Task"] = "TASK";
|
|
47
48
|
QueryTypeEnum["Unit"] = "UNIT";
|
|
48
49
|
QueryTypeEnum["Post"] = "POST";
|
|
49
50
|
QueryTypeEnum["Shop"] = "SHOP";
|
|
50
51
|
QueryTypeEnum["Brand"] = "BRAND";
|
|
51
52
|
QueryTypeEnum["Order"] = "ORDER";
|
|
52
53
|
QueryTypeEnum["Quote"] = "QUOTE";
|
|
54
|
+
QueryTypeEnum["Section"] = "SECTION";
|
|
53
55
|
QueryTypeEnum["Message"] = "MESSAGE";
|
|
54
56
|
QueryTypeEnum["Catalog"] = "CATALOG";
|
|
55
57
|
QueryTypeEnum["Product"] = "PRODUCT";
|
|
@@ -58,22 +60,21 @@ var QueryTypeEnum;
|
|
|
58
60
|
QueryTypeEnum["Expense"] = "EXPENSE";
|
|
59
61
|
QueryTypeEnum["Profile"] = "PROFILE";
|
|
60
62
|
QueryTypeEnum["Variant"] = "VARIANT";
|
|
63
|
+
QueryTypeEnum["Project"] = "PROJECT";
|
|
64
|
+
QueryTypeEnum["Pipeline"] = "PIPELINE";
|
|
65
|
+
QueryTypeEnum["Customer"] = "CUSTOMER";
|
|
61
66
|
QueryTypeEnum["Checkout"] = "CHECKOUT";
|
|
62
67
|
QueryTypeEnum["Category"] = "CATEGORY";
|
|
68
|
+
QueryTypeEnum["Discount"] = "DISCOUNT";
|
|
63
69
|
QueryTypeEnum["Warehouse"] = "WAREHOUSE";
|
|
64
70
|
QueryTypeEnum["OrderItem"] = "ORDERITEM";
|
|
65
71
|
QueryTypeEnum["QuoteItem"] = "QUOTEITEM";
|
|
66
72
|
QueryTypeEnum["QuoteOption"] = "QUOTEOPTION";
|
|
67
|
-
QueryTypeEnum["Section"] = "SECTION";
|
|
68
|
-
QueryTypeEnum["Discount"] = "DISCOUNT";
|
|
69
|
-
QueryTypeEnum["Project"] = "PROJECT";
|
|
70
73
|
QueryTypeEnum["UserAddress"] = "USERADDRESS";
|
|
71
74
|
QueryTypeEnum["Subcategory"] = "SUBCATEGORY";
|
|
72
75
|
QueryTypeEnum["ExpenseItem"] = "EXPENSEITEM";
|
|
73
76
|
QueryTypeEnum["Organization"] = "ORGANIZATION";
|
|
74
77
|
QueryTypeEnum["ApplicationSection"] = "APPLICATIONSECTION";
|
|
75
|
-
QueryTypeEnum["Task"] = "TASK";
|
|
76
|
-
QueryTypeEnum["Pipeline"] = "PIPELINE";
|
|
77
78
|
})(QueryTypeEnum || (exports.QueryTypeEnum = QueryTypeEnum = {}));
|
|
78
79
|
/**
|
|
79
80
|
* Activity model enum
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatPercent = exports.formatePrice = exports.calculDiscount = exports.calculVat = exports.toCents = exports.fromCents = void 0;
|
|
4
|
+
const isNaNumber = (value) => (!isNaN(Number(value)) ? value : 0);
|
|
4
5
|
/**
|
|
5
6
|
* @example
|
|
6
7
|
* fromCents(2300) // 23
|
|
@@ -30,9 +31,8 @@ exports.calculDiscount = calculDiscount;
|
|
|
30
31
|
* formatePrice({ value: 2300, currency: 'EUR', locale: 'fr' }) // 23.00 €
|
|
31
32
|
*/
|
|
32
33
|
const formatePrice = ({ value, currency, locale = "en", isDivide = false, }) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const numberCal = isDivide ? (0, exports.fromCents)(value) : value;
|
|
34
|
+
const newValue = isNaNumber(value);
|
|
35
|
+
const numberCal = isDivide ? (0, exports.fromCents)(newValue) : newValue;
|
|
36
36
|
const lang = ["fr", "it"].includes(locale.toLowerCase()) ? "de" : locale;
|
|
37
37
|
return new Intl.NumberFormat(lang, {
|
|
38
38
|
currency,
|
|
@@ -47,10 +47,12 @@ exports.formatePrice = formatePrice;
|
|
|
47
47
|
* formatPercent({ value: 20, locale: 'fr' }) // 20%
|
|
48
48
|
*/
|
|
49
49
|
const formatPercent = ({ value, locale, }) => {
|
|
50
|
-
|
|
50
|
+
const newValue = isNaNumber(value);
|
|
51
|
+
const result = new Intl.NumberFormat(locale, {
|
|
51
52
|
style: "percent",
|
|
52
53
|
notation: "standard",
|
|
53
54
|
maximumFractionDigits: 1,
|
|
54
|
-
}).format(
|
|
55
|
+
}).format(newValue / 100);
|
|
56
|
+
return result;
|
|
55
57
|
};
|
|
56
58
|
exports.formatPercent = formatPercent;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.
|
|
1
|
+
{"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.29","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"date-fns":"^4.3.0","luxon":"^3.7.2"}}
|