@chevre/domain 24.1.0-alpha.4 → 24.1.0-alpha.5
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/README.md +0 -2
- package/lib/chevre/repo/accountingReport.d.ts +9 -2
- package/lib/chevre/repo/accountingReport.js +6 -6
- package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -3
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +58 -63
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
- package/lib/chevre/service/task/createAccountingReport.js +9 -7
- package/lib/chevre/service/task/useReservation.d.ts +2 -2
- package/lib/chevre/service/task/useReservation.js +5 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Chevre Domain Library for Node.js
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@chevre/domain)
|
|
4
|
-
[](https://circleci.com/gh/chevre-jp/domain)
|
|
5
|
-
[](https://coveralls.io/github/chevre-jp/domain?branch=master)
|
|
6
4
|
[](https://snyk.io/test/github/chevre-jp/domain)
|
|
7
5
|
[](https://nodei.co/npm/@chevre/domain/)
|
|
8
6
|
|
|
@@ -2,6 +2,11 @@ import type { Connection, PipelineStage } from 'mongoose';
|
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
import { IDocType } from './mongoose/schemas/accountingReport';
|
|
4
4
|
type IMatchStage = PipelineStage.Match;
|
|
5
|
+
type IReportAsFindResult = Pick<factory.report.accountingReport.IReport, 'mainEntity'> & {
|
|
6
|
+
isPartOf: {
|
|
7
|
+
mainEntity: factory.report.accountingReport.IOrderAsMainEntity;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
5
10
|
/**
|
|
6
11
|
* 経理レポートリポジトリ
|
|
7
12
|
*/
|
|
@@ -35,11 +40,13 @@ export declare class AccountingReportRepo {
|
|
|
35
40
|
};
|
|
36
41
|
hasPart: factory.report.accountingReport.IChildReport;
|
|
37
42
|
}): Promise<void>;
|
|
38
|
-
|
|
43
|
+
findAccountingReports(params: factory.report.accountingReport.ISearchConditions & {
|
|
39
44
|
seller?: {
|
|
40
45
|
id?: string;
|
|
41
46
|
};
|
|
42
|
-
|
|
47
|
+
limit: number;
|
|
48
|
+
page: number;
|
|
49
|
+
}): Promise<IReportAsFindResult[]>;
|
|
43
50
|
unsetUnnecessaryFields(params: {
|
|
44
51
|
filter: any;
|
|
45
52
|
$unset: any;
|
|
@@ -4,7 +4,6 @@ exports.AccountingReportRepo = void 0;
|
|
|
4
4
|
const errorHandler_1 = require("../errorHandler");
|
|
5
5
|
const factory_1 = require("../factory");
|
|
6
6
|
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
7
|
-
const DEFAULT_SEARCH_LIMIT = 100;
|
|
8
7
|
/**
|
|
9
8
|
* 経理レポートリポジトリ
|
|
10
9
|
*/
|
|
@@ -137,9 +136,8 @@ class AccountingReportRepo {
|
|
|
137
136
|
throw new factory_1.factory.errors.NotFound(this.accountingReportModel.modelName);
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
|
-
async
|
|
141
|
-
const
|
|
142
|
-
const page = (typeof params.page === 'number') ? Math.max(params.page, 1) : 1;
|
|
139
|
+
async findAccountingReports(params) {
|
|
140
|
+
const { limit, page } = params;
|
|
143
141
|
const unwindAcceptedOffers = params.$unwindAcceptedOffers === '1';
|
|
144
142
|
const matchStages = AccountingReportRepo.CREATE_MONGO_CONDITIONS(params);
|
|
145
143
|
const aggregate = this.accountingReportModel.aggregate([
|
|
@@ -159,9 +157,11 @@ class AccountingReportRepo {
|
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
159
|
]);
|
|
162
|
-
return aggregate
|
|
163
|
-
.limit(limit * page)
|
|
160
|
+
return aggregate
|
|
161
|
+
// .limit(limit * page)
|
|
162
|
+
// .skip(limit * (page - 1))
|
|
164
163
|
.skip(limit * (page - 1))
|
|
164
|
+
.limit(limit)
|
|
165
165
|
// .setOptions({ maxTimeMS: 10000 })
|
|
166
166
|
.exec();
|
|
167
167
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
2
|
import { factory } from '../../factory';
|
|
3
|
-
export declare function createAccountingReportIfNotExist(params: Pick<factory.order.IOrder, 'id' | 'orderNumber' | 'project' | 'customer' | 'confirmationNumber' | 'paymentMethods' | '
|
|
4
|
-
acceptedOffers: factory.order.IAcceptedOffer[];
|
|
5
|
-
}): (repos: {
|
|
3
|
+
export declare function createAccountingReportIfNotExist(params: Pick<factory.order.IOrder, 'id' | 'orderNumber' | 'project' | 'customer' | 'confirmationNumber' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf' | 'orderDate'> & {}): (repos: {
|
|
6
4
|
accountingReport: AccountingReportRepo;
|
|
7
5
|
}) => Promise<void>;
|
|
@@ -19,84 +19,79 @@ function createAccountingReportIfNotExist(params) {
|
|
|
19
19
|
}
|
|
20
20
|
// 最適化(2023-06-30~)
|
|
21
21
|
function createOrder4report(params) {
|
|
22
|
-
if (!Array.isArray(params.acceptedOffers)) {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
const numItems = params.acceptedOffers.length;
|
|
26
|
-
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
27
|
-
const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
: [];
|
|
22
|
+
// if (!Array.isArray(params.acceptedOffers)) {
|
|
23
|
+
// throw new factory.errors.ArgumentNull('order.acceptedOffers');
|
|
24
|
+
// }
|
|
25
|
+
// const numItems: number = params.acceptedOffers.length;
|
|
26
|
+
// // 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
27
|
+
// const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
28
|
+
// ? params.acceptedOffers.map((o) => {
|
|
29
|
+
// if (o.itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
30
|
+
// let itemOffered = o.itemOffered;
|
|
31
|
+
// const reservationFor = itemOffered.reservationFor;
|
|
32
|
+
// itemOffered = {
|
|
33
|
+
// ...itemOffered,
|
|
34
|
+
// reservationFor: {
|
|
35
|
+
// ...reservationFor,
|
|
36
|
+
// ...(reservationFor.doorTime !== undefined)
|
|
37
|
+
// ? {
|
|
38
|
+
// doorTime: moment(reservationFor.doorTime)
|
|
39
|
+
// .toDate()
|
|
40
|
+
// }
|
|
41
|
+
// : undefined,
|
|
42
|
+
// ...(reservationFor.endDate !== undefined)
|
|
43
|
+
// ? {
|
|
44
|
+
// endDate: moment(reservationFor.endDate)
|
|
45
|
+
// .toDate()
|
|
46
|
+
// }
|
|
47
|
+
// : undefined,
|
|
48
|
+
// ...(reservationFor.startDate !== undefined)
|
|
49
|
+
// ? {
|
|
50
|
+
// startDate: moment(reservationFor.startDate)
|
|
51
|
+
// .toDate()
|
|
52
|
+
// }
|
|
53
|
+
// : undefined
|
|
54
|
+
// }
|
|
55
|
+
// } as factory.order.IReservation;
|
|
56
|
+
// return {
|
|
57
|
+
// ...o,
|
|
58
|
+
// itemOffered
|
|
59
|
+
// };
|
|
60
|
+
// } else {
|
|
61
|
+
// return o;
|
|
62
|
+
// }
|
|
63
|
+
// })
|
|
64
|
+
// : [];
|
|
66
65
|
const customer = {
|
|
67
|
-
// ...createMaskedCustomer(params),
|
|
68
66
|
id: params.customer.id,
|
|
69
67
|
typeOf: params.customer.typeOf,
|
|
70
|
-
additionalProperty: (Array.isArray(params.customer.additionalProperty))
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
identifier: (Array.isArray(params.customer.identifier))
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
// additionalProperty: (Array.isArray(params.customer.additionalProperty))
|
|
69
|
+
// ? params.customer.additionalProperty
|
|
70
|
+
// : [], // discontinue(2026-05-06~)
|
|
71
|
+
// identifier: (Array.isArray(params.customer.identifier))
|
|
72
|
+
// ? params.customer.identifier
|
|
73
|
+
// : [] // discontinue(2026-05-06~)
|
|
76
74
|
};
|
|
77
75
|
return {
|
|
78
|
-
// ...params,
|
|
79
76
|
confirmationNumber: params.confirmationNumber,
|
|
80
77
|
id: params.id,
|
|
81
78
|
orderNumber: params.orderNumber,
|
|
82
|
-
orderedItem: params.orderedItem,
|
|
83
79
|
paymentMethods: params.paymentMethods,
|
|
84
80
|
price: params.price,
|
|
85
81
|
priceCurrency: params.priceCurrency,
|
|
86
|
-
seller:
|
|
82
|
+
seller: {
|
|
83
|
+
id: params.seller.id,
|
|
84
|
+
name: params.seller.name,
|
|
85
|
+
typeOf: params.seller.typeOf
|
|
86
|
+
},
|
|
87
87
|
typeOf: params.typeOf,
|
|
88
88
|
customer,
|
|
89
89
|
orderDate: (0, moment_timezone_1.default)(params.orderDate)
|
|
90
90
|
.toDate(),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// ...(params.
|
|
95
|
-
// ? {
|
|
96
|
-
// dateReturned: moment(params.dateReturned)
|
|
97
|
-
// .toDate()
|
|
98
|
-
// }
|
|
99
|
-
// : undefined
|
|
91
|
+
// numItems, // discontinue(2026-05-06~)
|
|
92
|
+
// orderedItem: params.orderedItem, // discontinue(2026-05-06~)
|
|
93
|
+
// acceptedOffers, // discontinue(2026-05-06~)
|
|
94
|
+
// ...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined // discontinue(2026-05-06~)
|
|
100
95
|
};
|
|
101
96
|
}
|
|
102
97
|
function createAccountingReport(params) {
|
|
@@ -20,7 +20,7 @@ export declare function useReservation(params: {
|
|
|
20
20
|
*/
|
|
21
21
|
id: string;
|
|
22
22
|
};
|
|
23
|
-
instrument
|
|
23
|
+
instrument: factory.action.consume.use.reservation.IInstrument[];
|
|
24
24
|
location?: {
|
|
25
25
|
identifier?: string;
|
|
26
26
|
};
|
|
@@ -27,8 +27,10 @@ function createAccountingReport(params) {
|
|
|
27
27
|
orderNumber: data.object.mainEntity.orderNumber,
|
|
28
28
|
project: { id: params.project.id },
|
|
29
29
|
inclusion: [
|
|
30
|
-
'orderNumber', 'project', 'customer', 'confirmationNumber',
|
|
31
|
-
|
|
30
|
+
'orderNumber', 'project', 'customer', 'confirmationNumber', 'paymentMethods',
|
|
31
|
+
// 'orderedItem',
|
|
32
|
+
// 'broker',
|
|
33
|
+
'price', 'priceCurrency', 'seller', 'typeOf', 'orderDate'
|
|
32
34
|
] // explicit projection(2024-07-25~)
|
|
33
35
|
});
|
|
34
36
|
const simpleOrder = {
|
|
@@ -51,13 +53,13 @@ function createAccountingReport(params) {
|
|
|
51
53
|
};
|
|
52
54
|
const action = await repos.action.start(actionAttributes);
|
|
53
55
|
try {
|
|
54
|
-
const acceptedOffers = await repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
56
|
+
// const acceptedOffers = await repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
57
|
+
// orderNumber: { $eq: data.object.mainEntity.orderNumber },
|
|
58
|
+
// project: { id: { $eq: params.project.id } }
|
|
59
|
+
// });
|
|
58
60
|
await (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)({
|
|
59
61
|
...order,
|
|
60
|
-
acceptedOffers
|
|
62
|
+
// acceptedOffers
|
|
61
63
|
})(repos);
|
|
62
64
|
}
|
|
63
65
|
catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
|
|
1
2
|
import { factory } from '../../factory';
|
|
2
|
-
import type { IOperationExecute } from '../taskHandler';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(params: Pick<factory.task.useReservation.ITask, IExecutableTaskKeys>): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.call = call;
|
|
4
|
-
const factory_1 = require("../../factory");
|
|
5
4
|
const action_1 = require("../../repo/action");
|
|
6
5
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
7
6
|
const authorization_1 = require("../../repo/authorization");
|
|
@@ -13,25 +12,15 @@ const useReservation_1 = require("../reserve/useReservation");
|
|
|
13
12
|
/**
|
|
14
13
|
* タスク実行関数
|
|
15
14
|
*/
|
|
16
|
-
function call(
|
|
15
|
+
function call(params) {
|
|
17
16
|
return async ({ connection }) => {
|
|
18
|
-
|
|
19
|
-
// support array(2025-02-17~)
|
|
20
|
-
if (Array.isArray(data.instrument)) {
|
|
21
|
-
instrument = data.instrument;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw new factory_1.factory.errors.NotImplemented('instrument as object discontinued');
|
|
25
|
-
// if (data.instrument?.typeOf === 'Ticket') {
|
|
26
|
-
// instrument = [data.instrument];
|
|
27
|
-
// }
|
|
28
|
-
}
|
|
17
|
+
const { data, project } = params;
|
|
29
18
|
await (0, useReservation_1.useReservation)({
|
|
30
|
-
project
|
|
19
|
+
project,
|
|
31
20
|
agent: data.agent,
|
|
32
21
|
object: data.object,
|
|
33
|
-
instrument,
|
|
34
|
-
...(typeof data.location?.
|
|
22
|
+
instrument: data.instrument,
|
|
23
|
+
...(typeof data.location?.identifier === 'string') ? { location: data.location } : undefined
|
|
35
24
|
})({
|
|
36
25
|
action: new action_1.ActionRepo(connection),
|
|
37
26
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
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": "8.1.0-alpha.
|
|
14
|
+
"@chevre/factory": "8.1.0-alpha.2",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "24.1.0-alpha.
|
|
94
|
+
"version": "24.1.0-alpha.5"
|
|
95
95
|
}
|