@escapenavigator/utils 1.9.35 → 1.9.37

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.
@@ -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.35",
3
+ "version": "1.9.37",
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.35",
17
+ "@escapenavigator/types": "^1.9.36",
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": "e947f22312ae8065d243bba30186ab940a86be17"
58
+ "gitHead": "5e9dedbd83bb3fb1b46fe7ebac62a9d141f136a0"
59
59
  }