@escapenavigator/utils 1.9.36 → 1.9.38
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.
|
@@ -33,14 +33,31 @@ const getCurrency = (currency) => {
|
|
|
33
33
|
};
|
|
34
34
|
return res[currency] || currency;
|
|
35
35
|
};
|
|
36
|
+
const currencyFirst = (currency) => currency === 'EUR' ||
|
|
37
|
+
currency === 'USD' ||
|
|
38
|
+
currency === 'CHF' ||
|
|
39
|
+
currency === 'GBP' ||
|
|
40
|
+
currency === 'CAD' ||
|
|
41
|
+
currency === 'AUD' ||
|
|
42
|
+
currency === 'TRY' ||
|
|
43
|
+
currency === 'GEL' ||
|
|
44
|
+
currency === 'UAH';
|
|
36
45
|
const THINSP = String.fromCharCode(8201);
|
|
37
46
|
const formatAmount = (amount, currency) => {
|
|
38
47
|
const [major, minor] = ((+amount || 0) / 100).toFixed(2).split('.');
|
|
39
48
|
const value = +minor;
|
|
49
|
+
const c = getCurrency(currency);
|
|
50
|
+
if (currencyFirst) {
|
|
51
|
+
if (!value)
|
|
52
|
+
return c + THINSP + major;
|
|
53
|
+
if (value < 10)
|
|
54
|
+
return `${c}${THINSP}${major},${value}0`;
|
|
55
|
+
return `${c}${THINSP}${major},${value}`;
|
|
56
|
+
}
|
|
40
57
|
if (!value)
|
|
41
|
-
return major + THINSP +
|
|
58
|
+
return major + THINSP + c;
|
|
42
59
|
if (value < 10)
|
|
43
|
-
return `${major},${value}0${THINSP}${
|
|
44
|
-
return `${major},${value}${THINSP}${
|
|
60
|
+
return `${major},${value}0${THINSP}${c}`;
|
|
61
|
+
return `${major},${value}${THINSP}${c}`;
|
|
45
62
|
};
|
|
46
63
|
exports.formatAmount = formatAmount;
|
|
@@ -82,7 +82,7 @@ function getOrderCancelationState({ cancelationReason, cancelationRule, cancelat
|
|
|
82
82
|
}
|
|
83
83
|
if (chargeAmount < 0) {
|
|
84
84
|
const returnAmount = +(chargeAmount * -1).toFixed(0);
|
|
85
|
-
const allowAutoReturn = autoReturtAvailable && receivedTransactionsAmount >= returnAmount;
|
|
85
|
+
const allowAutoReturn = !slotDiscount && autoReturtAvailable && receivedTransactionsAmount >= returnAmount;
|
|
86
86
|
return {
|
|
87
87
|
type: allowAutoReturn ? FineDescriptions.AUTO_RETURN : FineDescriptions.HAND_RETURN,
|
|
88
88
|
fineAmount,
|
|
@@ -188,6 +188,34 @@ describe('getOrderCancelationState function', () => {
|
|
|
188
188
|
allowedCancelation: false,
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
|
+
test('should return "no charge / hand return / with slot discount" if not alowed cancelation has overpayment', () => {
|
|
192
|
+
const result = (0, _1.getOrderCancelationState)({
|
|
193
|
+
cancelationReason: order_cancel_reson_enum_1.OrderCancelReasonEnum.CLIENT,
|
|
194
|
+
slotDiscount: 10,
|
|
195
|
+
cancelationAmount: 0,
|
|
196
|
+
cancelationRule: questroom_cancelation_type_enum_1.QuestroomCancelationTypeEnum.HALF_PRICE,
|
|
197
|
+
transactions: [
|
|
198
|
+
{
|
|
199
|
+
amount: 100,
|
|
200
|
+
type: transaction_type_enum_1.TransactionTypeEnum.SUCCEEDED,
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
date: new Date().toISOString(),
|
|
204
|
+
returnCertificates: true,
|
|
205
|
+
certificates: [],
|
|
206
|
+
minHoursForFreeCanceling: 48,
|
|
207
|
+
total: 100,
|
|
208
|
+
payed: 100,
|
|
209
|
+
minimalPrice: 50,
|
|
210
|
+
});
|
|
211
|
+
expect(result).toEqual({
|
|
212
|
+
type: 'descriptionFineWithReturn',
|
|
213
|
+
fineAmount: 50,
|
|
214
|
+
returnAmount: 40,
|
|
215
|
+
chargeAmount: 0,
|
|
216
|
+
allowedCancelation: false,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
191
219
|
test('should return "with charge / no return" if not alowed cancelation has overpayment', () => {
|
|
192
220
|
const result = (0, _1.getOrderCancelationState)({
|
|
193
221
|
cancelationReason: order_cancel_reson_enum_1.OrderCancelReasonEnum.CLIENT,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/utils",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.38",
|
|
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.9.
|
|
17
|
+
"@escapenavigator/types": "^1.9.37",
|
|
18
18
|
"axios": "^0.21.4",
|
|
19
19
|
"class-transformer": "^0.5.1",
|
|
20
20
|
"class-validator": "^0.13.2",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"node_modules"
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "1c23f2d861f888faada1a7f58ef1cfe97ea908b3"
|
|
59
59
|
}
|