@chevre/domain 21.20.0-alpha.9 → 21.20.0
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.
- package/example/src/chevre/findTransactionById.ts +21 -0
- package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
- package/example/src/chevre/importOffersFromCOA.ts +2 -1
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
- package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
- package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
- package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
- package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchActions.ts +13 -7
- package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -1
- package/example/src/verifyToken.ts +44 -0
- package/lib/chevre/credentials.d.ts +2 -0
- package/lib/chevre/credentials.js +4 -2
- package/lib/chevre/errorHandler.js +3 -0
- package/lib/chevre/factory/order.d.ts +1 -0
- package/lib/chevre/factory/order.js +2 -1
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
- package/lib/chevre/factory/transaction.d.ts +10 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
- package/lib/chevre/repo/acceptedOffer.js +100 -4
- package/lib/chevre/repo/accountingReport.d.ts +33 -7
- package/lib/chevre/repo/accountingReport.js +157 -5
- package/lib/chevre/repo/action.d.ts +32 -8
- package/lib/chevre/repo/action.js +114 -54
- package/lib/chevre/repo/event.d.ts +20 -0
- package/lib/chevre/repo/event.js +22 -0
- package/lib/chevre/repo/member.d.ts +8 -1
- package/lib/chevre/repo/member.js +7 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
- package/lib/chevre/repo/offer.d.ts +42 -0
- package/lib/chevre/repo/offer.js +35 -0
- package/lib/chevre/repo/order.js +43 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
- package/lib/chevre/repo/orderInTransaction.js +164 -0
- package/lib/chevre/repo/paymentServiceProvider.js +2 -1
- package/lib/chevre/repo/person.js +1 -4
- package/lib/chevre/repo/task.d.ts +26 -3
- package/lib/chevre/repo/task.js +61 -46
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transaction.js +13 -36
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
- package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
- package/lib/chevre/service/assetTransaction/pay.d.ts +21 -1
- package/lib/chevre/service/assetTransaction/pay.js +64 -23
- package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
- package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +16 -24
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +71 -66
- package/lib/chevre/service/offer/any.d.ts +35 -0
- package/lib/chevre/service/offer/any.js +67 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +27 -17
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +13 -1
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +11 -22
- package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product/factory.js +2 -5
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +11 -23
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +4 -4
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +3 -1
- package/lib/chevre/service/order/placeOrder.js +157 -50
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +67 -33
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -2
- package/lib/chevre/service/payment/any.js +3 -2
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +62 -68
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
- package/lib/chevre/service/payment.d.ts +5 -0
- package/lib/chevre/service/payment.js +40 -5
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/checkInReservation.js +6 -5
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/factory.js +0 -8
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/searchByOrder.js +2 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/useReservation.js +10 -9
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
- package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
- package/lib/chevre/service/task/createAccountingReport.js +80 -0
- package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/pay.js +6 -0
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/useReservation.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
- package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
- package/lib/chevre/service/transaction/placeOrder.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
- package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
- package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
- package/lib/chevre/service/transaction/returnOrder.js +3 -10
- package/lib/chevre/service.js +0 -10
- package/lib/chevre/settings.d.ts +7 -3
- package/lib/chevre/settings.js +13 -4
- package/package.json +5 -9
- package/example/src/chevre/cleanAccountingReports.ts +0 -57
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
- package/lib/chevre/service/util.d.ts +0 -19
- package/lib/chevre/service/util.js +0 -126
|
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
13
|
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
14
14
|
const errorHandler_1 = require("../errorHandler");
|
|
15
|
+
const factory = require("../factory");
|
|
16
|
+
const DEFAULT_SEARCH_LIMIT = 100;
|
|
15
17
|
/**
|
|
16
18
|
* 経理レポートリポジトリ
|
|
17
19
|
*/
|
|
@@ -19,13 +21,103 @@ class MongoRepository {
|
|
|
19
21
|
constructor(connection) {
|
|
20
22
|
this.accountingReportModel = connection.model(accountingReport_1.modelName, (0, accountingReport_1.createSchema)());
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
26
|
+
const matchStages = [];
|
|
27
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
28
|
+
if (typeof projectIdEq === 'string') {
|
|
29
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
30
|
+
}
|
|
31
|
+
// req.seller.idを考慮(2023-07-21~)
|
|
32
|
+
if (typeof ((_c = params.seller) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
|
|
33
|
+
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: params.seller.id } } });
|
|
34
|
+
}
|
|
35
|
+
const orderNumberEq = (_e = (_d = params.order) === null || _d === void 0 ? void 0 : _d.orderNumber) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
36
|
+
if (typeof orderNumberEq === 'string') {
|
|
37
|
+
matchStages.push({ $match: { 'mainEntity.orderNumber': { $eq: orderNumberEq } } });
|
|
38
|
+
}
|
|
39
|
+
const sellerIdEq = (_h = (_g = (_f = params.order) === null || _f === void 0 ? void 0 : _f.seller) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
40
|
+
if (typeof sellerIdEq === 'string') {
|
|
41
|
+
matchStages.push({ $match: { 'mainEntity.seller.id': { $exists: true, $eq: sellerIdEq } } });
|
|
42
|
+
}
|
|
43
|
+
const paymentMethodIdEq = (_l = (_k = (_j = params.order) === null || _j === void 0 ? void 0 : _j.paymentMethods) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
44
|
+
if (typeof paymentMethodIdEq === 'string') {
|
|
45
|
+
matchStages.push({
|
|
46
|
+
$match: { 'mainEntity.paymentMethods.paymentMethodId': { $exists: true, $eq: paymentMethodIdEq } }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const orderDateGte = (_o = (_m = params.order) === null || _m === void 0 ? void 0 : _m.orderDate) === null || _o === void 0 ? void 0 : _o.$gte;
|
|
50
|
+
if (orderDateGte instanceof Date) {
|
|
51
|
+
matchStages.push({
|
|
52
|
+
$match: { 'mainEntity.orderDate': { $gte: orderDateGte } }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const orderDateLte = (_q = (_p = params.order) === null || _p === void 0 ? void 0 : _p.orderDate) === null || _q === void 0 ? void 0 : _q.$lte;
|
|
56
|
+
if (orderDateLte instanceof Date) {
|
|
57
|
+
matchStages.push({
|
|
58
|
+
$match: { 'mainEntity.orderDate': { $lte: orderDateLte } }
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const reservationForStartDateGte = (_v = (_u = (_t = (_s = (_r = params.order) === null || _r === void 0 ? void 0 : _r.acceptedOffers) === null || _s === void 0 ? void 0 : _s.itemOffered) === null || _t === void 0 ? void 0 : _t.reservationFor) === null || _u === void 0 ? void 0 : _u.startDate) === null || _v === void 0 ? void 0 : _v.$gte;
|
|
62
|
+
if (reservationForStartDateGte instanceof Date) {
|
|
63
|
+
matchStages.push({
|
|
64
|
+
$match: {
|
|
65
|
+
'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': {
|
|
66
|
+
$exists: true,
|
|
67
|
+
$gte: reservationForStartDateGte
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const reservationForStartDateLte = (_0 = (_z = (_y = (_x = (_w = params.order) === null || _w === void 0 ? void 0 : _w.acceptedOffers) === null || _x === void 0 ? void 0 : _x.itemOffered) === null || _y === void 0 ? void 0 : _y.reservationFor) === null || _z === void 0 ? void 0 : _z.startDate) === null || _0 === void 0 ? void 0 : _0.$lte;
|
|
73
|
+
if (reservationForStartDateLte instanceof Date) {
|
|
74
|
+
matchStages.push({
|
|
75
|
+
$match: {
|
|
76
|
+
'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': {
|
|
77
|
+
$exists: true,
|
|
78
|
+
$lte: reservationForStartDateLte
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return matchStages;
|
|
84
|
+
}
|
|
85
|
+
// public async createIfNotExist(params: IAccountingReport) {
|
|
86
|
+
// try {
|
|
87
|
+
// await this.accountingReportModel.findOneAndUpdate(
|
|
88
|
+
// { 'mainEntity.orderNumber': params.mainEntity.orderNumber },
|
|
89
|
+
// { $setOnInsert: params },
|
|
90
|
+
// { upsert: true }
|
|
91
|
+
// )
|
|
92
|
+
// .exec();
|
|
93
|
+
// } catch (error) {
|
|
94
|
+
// let throwsError = true;
|
|
95
|
+
// if (await isMongoError(error)) {
|
|
96
|
+
// // すでにorderNumberが存在する場合ok
|
|
97
|
+
// if (error.code === MongoErrorCode.DuplicateKey) {
|
|
98
|
+
// throwsError = false;
|
|
99
|
+
// }
|
|
100
|
+
// }
|
|
101
|
+
// if (throwsError) {
|
|
102
|
+
// throw error;
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
106
|
+
syncMainEntity(params) {
|
|
26
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const setOnInsert = {
|
|
109
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
110
|
+
typeOf: 'Report',
|
|
111
|
+
hasPart: [],
|
|
112
|
+
mainEntity: {
|
|
113
|
+
orderNumber: params.mainEntity.orderNumber // orderNumberのみが最低限必要なのでなければ作成
|
|
114
|
+
}
|
|
115
|
+
};
|
|
27
116
|
try {
|
|
28
|
-
|
|
117
|
+
// なければ作成
|
|
118
|
+
yield this.accountingReportModel.updateOne({ 'mainEntity.orderNumber': { $eq: params.mainEntity.orderNumber } }, { $setOnInsert: setOnInsert }, {
|
|
119
|
+
upsert: true
|
|
120
|
+
})
|
|
29
121
|
.exec();
|
|
30
122
|
}
|
|
31
123
|
catch (error) {
|
|
@@ -40,6 +132,9 @@ class MongoRepository {
|
|
|
40
132
|
throw error;
|
|
41
133
|
}
|
|
42
134
|
}
|
|
135
|
+
// mainEntityを同期
|
|
136
|
+
yield this.accountingReportModel.updateOne({ 'mainEntity.orderNumber': { $eq: params.mainEntity.orderNumber } }, { $set: { mainEntity: params.mainEntity } })
|
|
137
|
+
.exec();
|
|
43
138
|
});
|
|
44
139
|
}
|
|
45
140
|
/**
|
|
@@ -51,5 +146,62 @@ class MongoRepository {
|
|
|
51
146
|
.exec();
|
|
52
147
|
});
|
|
53
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* 注文にアクションレポートを追加する
|
|
151
|
+
* 注文に対する経理レポート自体が未作成であれば自動的に作成する
|
|
152
|
+
*/
|
|
153
|
+
addChildReport(params) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const setOnInsert = {
|
|
156
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
157
|
+
typeOf: 'Report',
|
|
158
|
+
// hasPart: [],
|
|
159
|
+
mainEntity: {
|
|
160
|
+
orderNumber: params.mainEntity.orderNumber // orderNumberのみが最低限必要なのでなければ作成
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const doc = yield this.accountingReportModel.findOneAndUpdate({ 'mainEntity.orderNumber': { $eq: params.mainEntity.orderNumber } }, {
|
|
164
|
+
$addToSet: { hasPart: params.hasPart },
|
|
165
|
+
$setOnInsert: setOnInsert
|
|
166
|
+
}, {
|
|
167
|
+
projection: { _id: 1 },
|
|
168
|
+
upsert: true
|
|
169
|
+
})
|
|
170
|
+
.exec();
|
|
171
|
+
if (doc === null) {
|
|
172
|
+
throw new factory.errors.NotFound(this.accountingReportModel.modelName);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
search(params) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const limit = (typeof params.limit === 'number') ? Math.min(params.limit, DEFAULT_SEARCH_LIMIT) : DEFAULT_SEARCH_LIMIT;
|
|
179
|
+
const page = (typeof params.page === 'number') ? Math.max(params.page, 1) : 1;
|
|
180
|
+
const unwindAcceptedOffers = params.$unwindAcceptedOffers === '1';
|
|
181
|
+
const matchStages = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
182
|
+
const aggregate = this.accountingReportModel.aggregate([
|
|
183
|
+
// pipelineの順序に注意
|
|
184
|
+
// @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
|
|
185
|
+
{ $sort: { 'mainEntity.orderDate': factory.sortType.Descending } },
|
|
186
|
+
{ $unwind: '$hasPart' },
|
|
187
|
+
...(unwindAcceptedOffers) ? [{ $unwind: '$mainEntity.acceptedOffers' }] : [],
|
|
188
|
+
...matchStages,
|
|
189
|
+
{
|
|
190
|
+
$project: {
|
|
191
|
+
_id: 0,
|
|
192
|
+
mainEntity: '$hasPart.mainEntity',
|
|
193
|
+
isPartOf: {
|
|
194
|
+
mainEntity: '$mainEntity'
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
]);
|
|
199
|
+
return aggregate.allowDiskUse(true)
|
|
200
|
+
.limit(limit * page)
|
|
201
|
+
.skip(limit * (page - 1))
|
|
202
|
+
// .setOptions({ maxTimeMS: 10000 })
|
|
203
|
+
.exec();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
54
206
|
}
|
|
55
207
|
exports.MongoRepository = MongoRepository;
|
|
@@ -30,6 +30,7 @@ export interface IUseActionCountByOffer {
|
|
|
30
30
|
_id: string[];
|
|
31
31
|
useActionCount?: number;
|
|
32
32
|
}
|
|
33
|
+
type KeyOfAction = keyof factory.action.IAction<factory.action.IAttributes<factory.actionType, any, any>> | '_id';
|
|
33
34
|
interface IAggregationByStatus {
|
|
34
35
|
actionCount: number;
|
|
35
36
|
avgDuration: number;
|
|
@@ -57,7 +58,7 @@ export declare class MongoRepository {
|
|
|
57
58
|
/**
|
|
58
59
|
* アクション検索
|
|
59
60
|
*/
|
|
60
|
-
search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion:
|
|
61
|
+
search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion: KeyOfAction[], exclusion: KeyOfAction[]): Promise<IAction<T>[]>;
|
|
61
62
|
/**
|
|
62
63
|
* アクション開始
|
|
63
64
|
*/
|
|
@@ -78,10 +79,10 @@ export declare class MongoRepository {
|
|
|
78
79
|
/**
|
|
79
80
|
* アクション取消
|
|
80
81
|
*/
|
|
81
|
-
|
|
82
|
-
typeOf:
|
|
82
|
+
cancelWithVoid(params: {
|
|
83
|
+
typeOf: factory.actionType;
|
|
83
84
|
id: string;
|
|
84
|
-
}): Promise<
|
|
85
|
+
}): Promise<void>;
|
|
85
86
|
/**
|
|
86
87
|
* アクション失敗
|
|
87
88
|
*/
|
|
@@ -90,6 +91,12 @@ export declare class MongoRepository {
|
|
|
90
91
|
id: string;
|
|
91
92
|
error: Error;
|
|
92
93
|
}): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* アクション再開
|
|
96
|
+
*/
|
|
97
|
+
reStart(params: {
|
|
98
|
+
id: string;
|
|
99
|
+
}): Promise<void>;
|
|
93
100
|
/**
|
|
94
101
|
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
95
102
|
*/
|
|
@@ -136,6 +143,9 @@ export declare class MongoRepository {
|
|
|
136
143
|
actionStatus?: {
|
|
137
144
|
$eq?: factory.actionStatusType;
|
|
138
145
|
};
|
|
146
|
+
id?: {
|
|
147
|
+
$nin?: string[];
|
|
148
|
+
};
|
|
139
149
|
sort?: factory.action.ISortOrder;
|
|
140
150
|
}): Promise<IAction<T>[]>;
|
|
141
151
|
/**
|
|
@@ -150,11 +160,11 @@ export declare class MongoRepository {
|
|
|
150
160
|
id: string;
|
|
151
161
|
};
|
|
152
162
|
}): Promise<void>;
|
|
153
|
-
updateAuthorizeEventOfferAction
|
|
163
|
+
updateAuthorizeEventOfferAction(params: {
|
|
154
164
|
id: string;
|
|
155
|
-
object: factory.action.authorize.offer.eventService.IObject<
|
|
156
|
-
result: factory.action.authorize.offer.eventService.IResult<
|
|
157
|
-
}): Promise<factory.action.authorize.offer.eventService.IAction<
|
|
165
|
+
object: factory.action.authorize.offer.eventService.IObject<factory.service.webAPI.Identifier.COA>;
|
|
166
|
+
result: factory.action.authorize.offer.eventService.IResult<factory.service.webAPI.Identifier.COA>;
|
|
167
|
+
}): Promise<factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier.COA>>;
|
|
158
168
|
updateById(params: {
|
|
159
169
|
id: string;
|
|
160
170
|
update: any;
|
|
@@ -272,6 +282,20 @@ export declare class MongoRepository {
|
|
|
272
282
|
startThrough: Date;
|
|
273
283
|
}): Promise<IAggregateAction>;
|
|
274
284
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
285
|
+
/**
|
|
286
|
+
* 互換性維持対応専用
|
|
287
|
+
*/
|
|
288
|
+
fixInstrumentTransactionNumber(params: {
|
|
289
|
+
id: string;
|
|
290
|
+
instrument: {
|
|
291
|
+
transactionNumber: string;
|
|
292
|
+
};
|
|
293
|
+
object?: {
|
|
294
|
+
pendingTransaction?: {
|
|
295
|
+
transactionNumber?: string;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
}): Promise<void>;
|
|
275
299
|
private agggregateByStatus;
|
|
276
300
|
}
|
|
277
301
|
export {};
|