@chevre/domain 22.8.0-alpha.21 → 22.8.0-alpha.23

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.
@@ -1,7 +1,10 @@
1
1
  import * as factory from '../../../../factory';
2
2
  import type { ISetting } from '../../../../repo/setting';
3
3
  type IReturnedOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner'>;
4
- declare function createInformTasks(order: IReturnedOrder, setting: Pick<ISetting, 'onOrderStatusChanged'> | null): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
4
+ type IReturnAction = factory.action.transfer.returnAction.order.IAttributes & {
5
+ id: string;
6
+ };
7
+ declare function createInformTasks(order: IReturnedOrder, returnOrderAction: IReturnAction, setting: Pick<ISetting, 'onOrderStatusChanged'> | null): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
5
8
  /**
6
9
  * 注文返品後のアクション
7
10
  */
@@ -9,4 +12,4 @@ declare function createOnOrderReturnedTasksByTransaction(params: {
9
12
  order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'customer' | 'price' | 'priceCurrency' | 'orderDate'>;
10
13
  potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
11
14
  }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deletePerson").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
12
- export { createInformTasks, createOnOrderReturnedTasksByTransaction };
15
+ export { createInformTasks, createOnOrderReturnedTasksByTransaction, IReturnAction };
@@ -3,26 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createInformTasks = createInformTasks;
4
4
  exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
5
5
  const factory = require("../../../../factory");
6
- function createInformTasks(order,
7
- // settings: Settings,
8
- setting) {
9
- var _a, _b;
6
+ function createInformTasks(order, returnOrderAction, setting) {
7
+ var _a, _b, _c;
10
8
  const taskRunsAt = new Date();
11
- // const informOrder = settings.onOrderStatusChanged?.informOrder;
12
9
  const informOrder = (_a = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
10
+ const useInformReturnAction = ((_b = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _b === void 0 ? void 0 : _b.useInformReturnAction) === true;
13
11
  const informTasks = [];
14
- const order4inform = creteOrder4inform(order);
15
- const informIdentifier = `${factory.order.OrderType.Order}:${order4inform.orderNumber}:${order4inform.orderStatus}`;
12
+ // support returnAction4inform(2025-01-22~)
13
+ let informObject;
14
+ const informIdentifier = `${factory.order.OrderType.Order}:${order.orderNumber}:${factory.orderStatus.OrderReturned}`;
15
+ if (useInformReturnAction) {
16
+ informObject = createReturnAction4inform(returnOrderAction);
17
+ }
18
+ else {
19
+ informObject = createOrder4inform(order);
20
+ }
16
21
  if (Array.isArray(informOrder) && informOrder.length > 0) {
17
22
  let recipientId = '';
18
23
  recipientId = order.customer.id;
19
- if (typeof ((_b = order.returner) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
24
+ if (typeof ((_c = order.returner) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
20
25
  recipientId = order.returner.id;
21
26
  }
22
27
  informTasks.push(...informOrder.map((informOrderParams) => {
23
28
  var _a, _b;
24
29
  const informActionAttributes = {
25
- object: order4inform,
30
+ object: informObject,
26
31
  recipient: {
27
32
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
28
33
  id: recipientId,
@@ -45,7 +50,11 @@ setting) {
45
50
  }
46
51
  return informTasks;
47
52
  }
48
- function creteOrder4inform(order) {
53
+ function createReturnAction4inform(returnOrderAction) {
54
+ const { id, instrument, object, project, typeOf } = returnOrderAction;
55
+ return Object.assign({ id, object, project, typeOf }, (Array.isArray(instrument)) ? { instrument } : undefined);
56
+ }
57
+ function createOrder4inform(order) {
49
58
  return Object.assign(Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: factory.orderStatus.OrderReturned }, (order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
50
59
  }
51
60
  /**
@@ -2,12 +2,14 @@ import type { AcceptedOfferRepo } from '../../../repo/acceptedOffer';
2
2
  import type { SettingRepo } from '../../../repo/setting';
3
3
  import type { TaskRepo } from '../../../repo/task';
4
4
  import * as factory from '../../../factory';
5
+ import { IReturnAction } from './onOrderReturned/factory';
5
6
  type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
6
7
  declare function onOrderReturned(params: {
7
8
  order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
8
9
  orderStatus: factory.orderStatus.OrderReturned;
9
10
  };
10
- returnOrderTransaction?: IReturnOrderTransaction;
11
+ returnOrderTransaction: IReturnOrderTransaction;
12
+ returnOrderAction: IReturnAction;
11
13
  }): (repos: {
12
14
  acceptedOffer: AcceptedOfferRepo;
13
15
  setting: SettingRepo;
@@ -53,7 +53,7 @@ function onOrderReturned(params) {
53
53
  const offeredThroughIdentifier = (yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.offeredThrough.identifier'))[0];
54
54
  const reservationForSuperEventLocationBranchCodes = yield repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.order.orderNumber] } }, 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode');
55
55
  tasks = [
56
- ...(0, factory_1.createInformTasks)(params.order, setting),
56
+ ...(0, factory_1.createInformTasks)(params.order, params.returnOrderAction, setting),
57
57
  ...createReturnReserveTransactionTasks(Object.assign(Object.assign({}, params.order), { reservationNumbers,
58
58
  offeredThroughIdentifier,
59
59
  reservationForSuperEventLocationBranchCodes }), simpleOrder),
@@ -16,6 +16,11 @@ const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
16
16
  const factory = require("../../factory");
17
17
  // import { Settings } from '../../settings';
18
18
  const debug = createDebug('chevre-domain:service:order');
19
+ function createReturnPolicy(params) {
20
+ const { identifier, returnFees, restockingFee, typeOf } = params.returnOrderTransaction.object.returnPolicy;
21
+ return Object.assign(Object.assign({ returnFees,
22
+ typeOf }, (typeof identifier === 'string') ? { identifier } : undefined), (typeof (restockingFee === null || restockingFee === void 0 ? void 0 : restockingFee.value) === 'number') ? { restockingFee } : undefined);
23
+ }
19
24
  function returnOrder(params) {
20
25
  // tslint:disable-next-line:max-func-body-length
21
26
  return (repos
@@ -54,7 +59,7 @@ function returnOrder(params) {
54
59
  typeOf: factory.transactionType.ReturnOrder,
55
60
  statuses: [factory.transactionStatusType.Confirmed],
56
61
  object: { order: { orderNumbers: [orderNumber] } },
57
- inclusion: ['typeOf', 'potentialActions']
62
+ inclusion: ['typeOf', 'potentialActions', 'object']
58
63
  });
59
64
  const returnOrderTransaction = returnOrderTransactions.shift();
60
65
  if (returnOrderTransaction === undefined) {
@@ -62,23 +67,22 @@ function returnOrder(params) {
62
67
  }
63
68
  const simpleOrder = {
64
69
  typeOf: order.typeOf,
65
- // seller: {
66
- // id: order.seller.id,
67
- // typeOf: order.seller.typeOf,
68
- // name: order.seller.name
69
- // }, // 廃止(2024-03-06~)
70
- // customer: createMaskedCustomer(order, { noProfile: true }), // 廃止(2024-03-06~)
71
70
  orderNumber: order.orderNumber,
72
- // price: order.price,
73
- // priceCurrency: order.priceCurrency,
74
71
  orderDate: order.orderDate,
75
72
  dateReturned
76
73
  };
74
+ const recipient = {
75
+ id: order.seller.id,
76
+ name: order.seller.name,
77
+ typeOf: order.seller.typeOf
78
+ };
79
+ const returnPolicyAsInstrument = createReturnPolicy({ returnOrderTransaction });
77
80
  const returnOrderActionAttributes = {
78
81
  agent: returner,
82
+ instrument: [returnPolicyAsInstrument], // add returnPolicy(2025-01-21~)
79
83
  object: simpleOrder,
80
84
  project: order.project,
81
- recipient: order.seller,
85
+ recipient,
82
86
  typeOf: factory.actionType.ReturnAction
83
87
  };
84
88
  let returnedOwnershipInfos = [];
@@ -125,7 +129,8 @@ function returnOrder(params) {
125
129
  orderDate: returnedOrder.orderDate,
126
130
  orderStatus: factory.orderStatus.OrderReturned
127
131
  },
128
- returnOrderTransaction
132
+ returnOrderTransaction,
133
+ returnOrderAction: Object.assign(Object.assign({}, returnOrderActionAttributes), { id: action.id })
129
134
  })(repos
130
135
  // settings
131
136
  );
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.392.0-alpha.14",
15
- "@cinerino/sdk": "10.20.0-alpha.9",
14
+ "@chevre/factory": "4.392.0-alpha.16",
15
+ "@cinerino/sdk": "10.20.0-alpha.10",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.0",
@@ -112,5 +112,5 @@
112
112
  "postversion": "git push origin --tags",
113
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
114
114
  },
115
- "version": "22.8.0-alpha.21"
115
+ "version": "22.8.0-alpha.23"
116
116
  }