@chevre/domain 21.2.0-alpha.64 → 21.2.0-alpha.65
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
3
|
+
|
|
4
|
+
const startDate = moment('2023-05-24T16:00:00Z')
|
|
5
|
+
.toDate();
|
|
6
|
+
const gracePeriodBeforeStartInDaysMin = {
|
|
7
|
+
timezone: 'Asia/Tokyo',
|
|
8
|
+
time: '18:00:00',
|
|
9
|
+
period: { value: 2 }
|
|
10
|
+
};
|
|
11
|
+
const returningDate = new Date();
|
|
12
|
+
|
|
13
|
+
const minDate: string = moment(startDate)
|
|
14
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
15
|
+
.startOf('days')
|
|
16
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
17
|
+
.format('YYYY-MM-DD');
|
|
18
|
+
console.log('minDate:', minDate);
|
|
19
|
+
|
|
20
|
+
const returnMaxDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`)
|
|
21
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone);
|
|
22
|
+
console.log(returnMaxDate);
|
|
23
|
+
|
|
24
|
+
console.log(returnMaxDate.isSameOrAfter(moment(returningDate)));
|
|
@@ -133,31 +133,39 @@ exports.createReturnPaymentMethodActions = createReturnPaymentMethodActions;
|
|
|
133
133
|
function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
135
|
const order = params.order;
|
|
136
|
-
const
|
|
136
|
+
const returnFeesMovieTicketByTransaction = params.transaction.object.returnPolicy.returnFeesMovieTicket;
|
|
137
137
|
return Promise.all(params.order.paymentMethods
|
|
138
138
|
.filter((paymentMethod) => {
|
|
139
139
|
return paymentMethod.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
140
140
|
})
|
|
141
|
-
//
|
|
141
|
+
// 決済カード着券取消有無設定を適用
|
|
142
142
|
.filter((paymentMethod) => {
|
|
143
|
-
|
|
143
|
+
// デフォルトで実行する
|
|
144
|
+
let returnPaymentMethod = true;
|
|
144
145
|
const movieTicketIdentifier = paymentMethod.accountId;
|
|
145
|
-
const
|
|
146
|
+
const returnFeesMovieTicketSettingsByIdentifier = returnFeesMovieTicketByTransaction === null || returnFeesMovieTicketByTransaction === void 0 ? void 0 : returnFeesMovieTicketByTransaction.filter((r) => {
|
|
147
|
+
var _a;
|
|
148
|
+
return r.identifier === String(movieTicketIdentifier)
|
|
149
|
+
&& ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === paymentMethod.typeOf;
|
|
150
|
+
});
|
|
146
151
|
// 設定がなければスルー
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
if (Array.isArray(returnFeesMovieTicketSettingsByIdentifier) && returnFeesMovieTicketSettingsByIdentifier.length > 0) {
|
|
153
|
+
returnFeesMovieTicketSettingsByIdentifier.forEach((returnFeesMovieTicketSetting) => {
|
|
154
|
+
const returnFeesEnumeration = returnFeesMovieTicketSetting.returnFees;
|
|
155
|
+
switch (returnFeesEnumeration) {
|
|
156
|
+
case factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn:
|
|
157
|
+
break;
|
|
158
|
+
// ひとつでも「取消を実行しない」に設定されていれば、実行しない
|
|
159
|
+
case factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility:
|
|
160
|
+
// 取消実行しない
|
|
161
|
+
returnPaymentMethod = false;
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
throw new factory.errors.NotImplemented(`returnFees ${returnFeesEnumeration} not implemented`);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
160
167
|
}
|
|
168
|
+
return returnPaymentMethod;
|
|
161
169
|
})
|
|
162
170
|
.map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
163
171
|
const potentialActionsOnRefund = yield createReturnPaymentMethodPotentialActions({
|
|
@@ -13,7 +13,7 @@ exports.exportTasksById = exports.confirm = exports.start = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 返品取引サービス
|
|
15
15
|
*/
|
|
16
|
-
const moment = require("moment");
|
|
16
|
+
const moment = require("moment-timezone");
|
|
17
17
|
const factory = require("../../factory");
|
|
18
18
|
const factory_1 = require("./returnOrder/exportTasks/factory");
|
|
19
19
|
const potentialActions_1 = require("./returnOrder/potentialActions");
|
|
@@ -236,7 +236,7 @@ function findApplicableReturnPolicy(params) {
|
|
|
236
236
|
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
237
237
|
// 適用可能なポリシーにフィルター
|
|
238
238
|
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
239
|
-
var _a, _b, _c, _d, _e;
|
|
239
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
240
240
|
let satisfyMerchantReturnDays = false;
|
|
241
241
|
let offerItemCondition;
|
|
242
242
|
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -268,6 +268,8 @@ function findApplicableReturnPolicy(params) {
|
|
|
268
268
|
if (offerItemCondition !== undefined) {
|
|
269
269
|
let satisfyGracePeriodMaxValue = true;
|
|
270
270
|
let satisfyGracePeriodMinValue = true;
|
|
271
|
+
let satisfyGracePeriodInDaysMax = true;
|
|
272
|
+
let satisfyGracePeriodInDaysMin = true;
|
|
271
273
|
// 全イベントについて猶予の確認ができれば適用
|
|
272
274
|
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
273
275
|
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
@@ -285,7 +287,36 @@ function findApplicableReturnPolicy(params) {
|
|
|
285
287
|
.add(gracePeriodMinValue, 'seconds'));
|
|
286
288
|
});
|
|
287
289
|
}
|
|
288
|
-
|
|
290
|
+
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
291
|
+
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
292
|
+
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
293
|
+
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
294
|
+
const minDate = moment(event.startDate)
|
|
295
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
296
|
+
.startOf('days')
|
|
297
|
+
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
298
|
+
.format('YYYY-MM-DD');
|
|
299
|
+
const returnMinDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMax.time}`)
|
|
300
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone);
|
|
301
|
+
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
305
|
+
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
306
|
+
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
307
|
+
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
308
|
+
const minDate = moment(event.startDate)
|
|
309
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
310
|
+
.startOf('days')
|
|
311
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
312
|
+
.format('YYYY-MM-DD');
|
|
313
|
+
const returnMaxDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`)
|
|
314
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone);
|
|
315
|
+
return returnMaxDate.isSameOrAfter(moment(returningDate));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
319
|
+
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin;
|
|
289
320
|
}
|
|
290
321
|
return satisfyMerchantReturnDays && satisfyItemCondition;
|
|
291
322
|
});
|
|
@@ -402,7 +433,8 @@ function validateOffersReturnPolicy(params) {
|
|
|
402
433
|
component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
403
434
|
returnFeesMovieTicket.push({
|
|
404
435
|
identifier: String(appliesToMovieTicket.identifier),
|
|
405
|
-
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket
|
|
436
|
+
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket,
|
|
437
|
+
serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
|
|
406
438
|
});
|
|
407
439
|
});
|
|
408
440
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.8",
|
|
13
13
|
"@cinerino/sdk": "3.156.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.65"
|
|
121
121
|
}
|