@escapenavigator/utils 1.6.42 → 1.6.45
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/dist/format-amount/index.d.ts +2 -0
- package/dist/format-amount/index.js +23 -0
- package/dist/get-increase-by-type.d.ts +1 -2
- package/dist/get-increase-by-type.js +2 -2
- package/dist/get-order-cancelation-state/index.js +7 -10
- package/package.json +3 -3
- package/dist/get-currency.d.ts +0 -2
- package/dist/get-currency.js +0 -13
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatAmount = void 0;
|
|
4
|
+
const profile_currency_1 = require("@escapenavigator/types/dist/profile/enum/profile-currency");
|
|
5
|
+
const getCurrency = (currency) => {
|
|
6
|
+
const res = {
|
|
7
|
+
[profile_currency_1.ProfileCurrencyEnum.EUR]: '€',
|
|
8
|
+
[profile_currency_1.ProfileCurrencyEnum.USD]: '$',
|
|
9
|
+
[profile_currency_1.ProfileCurrencyEnum.RUR]: 'Р',
|
|
10
|
+
};
|
|
11
|
+
return res[currency] || currency;
|
|
12
|
+
};
|
|
13
|
+
const THINSP = String.fromCharCode(8201);
|
|
14
|
+
const formatAmount = (amount, currency) => {
|
|
15
|
+
const [major, minor] = ((+amount || 0) / 100).toFixed(2).split('.');
|
|
16
|
+
const value = +minor;
|
|
17
|
+
if (!value)
|
|
18
|
+
return major + THINSP + getCurrency(currency);
|
|
19
|
+
if (value < 10)
|
|
20
|
+
return `${major},${value}0${THINSP}${getCurrency(currency)}`;
|
|
21
|
+
return `${major},${value}${THINSP}${getCurrency(currency)}`;
|
|
22
|
+
};
|
|
23
|
+
exports.formatAmount = formatAmount;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { PrepaymentTypeEnum } from '@escapenavigator/types/dist/slot/enum/prepayment-type.enum';
|
|
2
1
|
declare type Props = {
|
|
3
2
|
increase: number;
|
|
4
|
-
increaseType:
|
|
3
|
+
increaseType: 'fixed' | 'percent' | 'no';
|
|
5
4
|
sum: number;
|
|
6
5
|
};
|
|
7
6
|
export declare const getIncreaseByType: ({ increase, increaseType, sum }: Props) => number;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getIncreaseByType = void 0;
|
|
4
4
|
const prepayment_type_enum_1 = require("@escapenavigator/types/dist/slot/enum/prepayment-type.enum");
|
|
5
5
|
const getIncreaseByType = ({ increase, increaseType, sum }) => {
|
|
6
|
-
if (increaseType ===
|
|
6
|
+
if (increaseType === 'no')
|
|
7
7
|
return 0;
|
|
8
|
-
return Math.round(increaseType === prepayment_type_enum_1.PrepaymentTypeEnum.FIXED ? increase : (sum /
|
|
8
|
+
return Math.round(increaseType === prepayment_type_enum_1.PrepaymentTypeEnum.FIXED ? increase : (sum / 10000) * increase);
|
|
9
9
|
};
|
|
10
10
|
exports.getIncreaseByType = getIncreaseByType;
|
|
@@ -24,9 +24,6 @@ var FineDescriptions;
|
|
|
24
24
|
const isCancelationAllowed = ({ date, minHoursForFreeCanceling = 0, }) => (0, differenceInHours_1.default)(new Date(date), new Date()) > minHoursForFreeCanceling;
|
|
25
25
|
exports.isCancelationAllowed = isCancelationAllowed;
|
|
26
26
|
function getOrderCancelationState({ cancelationReason, cancelationRule, transactions, date, returnCertificates, certificates, minHoursForFreeCanceling, total, payed, minimalPrice, }) {
|
|
27
|
-
/**
|
|
28
|
-
* В срок ли отменяется игра. Если в срок, то мы отменяем все промокоды и сертификаты, учитываем сумму возврата только с транзакций
|
|
29
|
-
*/
|
|
30
27
|
const minHours = cancelationRule === questroom_cancelation_type_enum_1.QuestroomCancelationTypeEnum.NO ? 0 : minHoursForFreeCanceling;
|
|
31
28
|
const allowedCancelation = cancelationReason === order_cancel_reson_enum_1.OrderCancelReasonEnum.QUESTROOM ||
|
|
32
29
|
(0, exports.isCancelationAllowed)({
|
|
@@ -51,7 +48,7 @@ function getOrderCancelationState({ cancelationReason, cancelationRule, transact
|
|
|
51
48
|
return {
|
|
52
49
|
fineAmount: 0,
|
|
53
50
|
chargeAmount: 0,
|
|
54
|
-
returnAmount: receivedTransactionsAmount,
|
|
51
|
+
returnAmount: +(receivedTransactionsAmount / 100).toFixed(2),
|
|
55
52
|
allowedCancelation,
|
|
56
53
|
type: fineAmount ? FineDescriptions.NO_FINE : FineDescriptions.FINE_TON_SETUP,
|
|
57
54
|
};
|
|
@@ -60,7 +57,7 @@ function getOrderCancelationState({ cancelationReason, cancelationRule, transact
|
|
|
60
57
|
return {
|
|
61
58
|
fineAmount: 0,
|
|
62
59
|
chargeAmount: 0,
|
|
63
|
-
returnAmount: receivedTransactionsAmount,
|
|
60
|
+
returnAmount: +(receivedTransactionsAmount / 100).toFixed(2),
|
|
64
61
|
allowedCancelation,
|
|
65
62
|
type: autoReturtAvailable ? FineDescriptions.AUTO_RETURN : FineDescriptions.HAND_RETURN,
|
|
66
63
|
};
|
|
@@ -73,7 +70,7 @@ function getOrderCancelationState({ cancelationReason, cancelationRule, transact
|
|
|
73
70
|
type: FineDescriptions.FINE_PAID,
|
|
74
71
|
returnAmount: 0,
|
|
75
72
|
chargeAmount: 0,
|
|
76
|
-
fineAmount,
|
|
73
|
+
fineAmount: +(fineAmount / 100).toFixed(2),
|
|
77
74
|
allowedCancelation,
|
|
78
75
|
};
|
|
79
76
|
}
|
|
@@ -82,17 +79,17 @@ function getOrderCancelationState({ cancelationReason, cancelationRule, transact
|
|
|
82
79
|
const allowAutoReturn = autoReturtAvailable && receivedTransactionsAmount >= returnAmount;
|
|
83
80
|
return {
|
|
84
81
|
type: allowAutoReturn ? FineDescriptions.AUTO_RETURN : FineDescriptions.HAND_RETURN,
|
|
85
|
-
fineAmount,
|
|
82
|
+
fineAmount: +(fineAmount / 100).toFixed(2),
|
|
86
83
|
chargeAmount: 0,
|
|
87
|
-
returnAmount,
|
|
84
|
+
returnAmount: +(returnAmount / 100).toFixed(2),
|
|
88
85
|
allowedCancelation,
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
return {
|
|
92
89
|
type: FineDescriptions.WITH_CHARGE,
|
|
93
|
-
fineAmount,
|
|
90
|
+
fineAmount: +(fineAmount / 100).toFixed(2),
|
|
94
91
|
returnAmount: 0,
|
|
95
|
-
chargeAmount,
|
|
92
|
+
chargeAmount: +(chargeAmount / 100).toFixed(2),
|
|
96
93
|
allowedCancelation,
|
|
97
94
|
};
|
|
98
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/utils",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.45",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test": "jest"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@escapenavigator/types": "^1.6.
|
|
17
|
+
"@escapenavigator/types": "^1.6.45",
|
|
18
18
|
"axios": "^0.21.4",
|
|
19
19
|
"class-transformer": "^0.5.1",
|
|
20
20
|
"class-validator": "^0.13.1",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"node_modules"
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "a68911b22a5aa8780088b6528661f4e4804fad1b"
|
|
59
59
|
}
|
package/dist/get-currency.d.ts
DELETED
package/dist/get-currency.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrency = void 0;
|
|
4
|
-
const profile_currency_1 = require("@escapenavigator/types/dist/profile/enum/profile-currency");
|
|
5
|
-
const getCurrency = (currency) => {
|
|
6
|
-
const res = {
|
|
7
|
-
[profile_currency_1.ProfileCurrencyEnum.EUR]: '€',
|
|
8
|
-
[profile_currency_1.ProfileCurrencyEnum.USD]: '$',
|
|
9
|
-
[profile_currency_1.ProfileCurrencyEnum.RUR]: 'Р',
|
|
10
|
-
};
|
|
11
|
-
return res[currency] || currency;
|
|
12
|
-
};
|
|
13
|
-
exports.getCurrency = getCurrency;
|