UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

113 lines (112 loc) 6.47 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.cancel = cancel; exports.cancelByAcceptAction = cancelByAcceptAction; const factory = require("../../../factory"); const cancelReservation_1 = require("../../reserveCOA/cancelReservation"); function cancel(params, options) { return (repos) => __awaiter(this, void 0, void 0, function* () { // object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す let delTmpReserveParams; // objectに進行中取引情報があれば利用する(2023-09-11~) const pendingTransaction = params.action.object.pendingTransaction; if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') { delTmpReserveParams = { theaterCode: pendingTransaction.theaterCode, dateJouei: pendingTransaction.dateJouei, titleCode: pendingTransaction.titleCode, titleBranchNum: pendingTransaction.titleBranchNum, timeBegin: pendingTransaction.timeBegin, tmpReserveNum: pendingTransaction.tmpReserveNum }; } if (delTmpReserveParams !== undefined) { const { asyncCancelPendingReservation } = options; const object = Object.assign(Object.assign({}, delTmpReserveParams), { reservationStatus: factory.reservationStatusType.ReservationPending, transactionNumber: delTmpReserveParams.tmpReserveNum, typeOf: factory.assetTransactionType.COAReserveTransaction }); const instrument = [params.action.purpose]; if (asyncCancelPendingReservation) { // support async(2025-03-03~) const data = { object, instrument }; const cancelPendingReservationTask = { project: { id: params.action.project.id, typeOf: factory.organizationType.Project }, name: factory.taskName.CancelPendingReservation, status: factory.taskStatus.Ready, runsAt: new Date(), remainingNumberOfTries: 10, numberOfTried: 0, executionResults: [], data }; yield repos.task.saveMany([cancelPendingReservationTask], { emitImmediately: true }); } else { yield (0, cancelReservation_1.cancelPendingReservation)({ project: { id: params.action.project.id }, object, instrument })(repos); } } }); } function cancelByAcceptAction(params, options) { return (repos) => __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f; const recipe = yield repos.action.findRecipeByAction({ project: { id: params.action.project.id }, recipeFor: { id: params.action.id } }); if (recipe !== null) { let delTmpReserveParams; // recipeから連携情報取得に変更(2024-06-11~) const coaRequestBody = (_c = (_b = (_a = recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia; const coaResponseBody = (_f = (_e = (_d = recipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia; if (coaRequestBody !== undefined && coaResponseBody !== undefined) { delTmpReserveParams = { theaterCode: coaRequestBody.theaterCode, dateJouei: coaRequestBody.dateJouei, titleCode: coaRequestBody.titleCode, titleBranchNum: coaRequestBody.titleBranchNum, timeBegin: coaRequestBody.timeBegin, tmpReserveNum: coaResponseBody.tmpReserveNum }; } if (delTmpReserveParams !== undefined) { const { asyncCancelPendingReservation } = options; const object = Object.assign(Object.assign({}, delTmpReserveParams), { reservationStatus: factory.reservationStatusType.ReservationPending, transactionNumber: delTmpReserveParams.tmpReserveNum, typeOf: factory.assetTransactionType.COAReserveTransaction }); const instrument = [params.action.purpose]; if (asyncCancelPendingReservation) { // support async(2025-03-03~) const data = { object, instrument }; const cancelPendingReservationTask = { project: { id: params.action.project.id, typeOf: factory.organizationType.Project }, name: factory.taskName.CancelPendingReservation, status: factory.taskStatus.Ready, runsAt: new Date(), remainingNumberOfTries: 10, numberOfTried: 0, executionResults: [], data }; yield repos.task.saveMany([cancelPendingReservationTask], { emitImmediately: true }); } else { yield (0, cancelReservation_1.cancelPendingReservation)({ project: { id: params.action.project.id }, object, instrument })(repos); } } } }); }