Merged PR 825: AzureFunctions実装2(取得したデータをCSV用に変換する)
## 概要 [Task3844: AzureFunctions実装2(取得したデータをCSV用に変換する)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3844) transferData()の実装 ccbの最新よりマージした状態での引数に変更 各ライセンス数をCSV配列に出力できるところまでを実装 (実際にローカルにCSV出力して中身を確認済み)  ※UIの変更ではない為、ここにそのまま張り付けさせていただきます。 ## レビューポイント - 関数化の範囲は適切か。 テストコードは最低限の記述になるが、問題ないか (33行*7項目の突合せをコード上に実装するのは時間的余裕がないためやってない) 詳細な動作確認は、別タスク https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation/_sprints/taskboard/OMDSDictation%20%E3%83%81%E3%83%BC%E3%83%A0/OMDSDictation/%E3%82%B9%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%2029-2?workitem=3861 で行います。 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
340aa73bde
commit
415fd2eb58
@ -337,3 +337,56 @@ export const RoleNumberMap: Record<number, string> = {
|
||||
export const SYSTEM_IMPORT_USERS = "import-users";
|
||||
|
||||
export const ROW_START_INDEX = 2;
|
||||
|
||||
/**
|
||||
* ライセンス数推移出力機能のCSVヘッダ
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const LICENSE_COUNT_ANALYSIS_HEADER = {
|
||||
ACCOUNT: "アカウント",
|
||||
TARGET_YEAE_AND_MONTH: "対象年月",
|
||||
CATEGORY_1: "カテゴリー1",
|
||||
CATEGORY_2: "カテゴリー2",
|
||||
LICENSE_TYPE: "ライセンス種別",
|
||||
ROLE: "役割",
|
||||
COUNT: "数量",
|
||||
};
|
||||
/**
|
||||
* ライセンス数推移出力機能のCSV項目で使用する日本語(カテゴリー1)
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const LICENSE_COUNT_ANALYSIS_CATEGORY_1 = {
|
||||
VALID_LICENSES: "有効ライセンス数",
|
||||
NEW_ISSUE_LICENSES: "新規発行ライセンス数",
|
||||
INVALID_LICENSES: "失効ライセンス数",
|
||||
SWICHED_LICENSES: "有効ライセンス切り替え",
|
||||
};
|
||||
/**
|
||||
* ライセンス数推移出力機能のCSV項目で使用する日本語(カテゴリー2)
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const LICENSE_COUNT_ANALYSIS_CATEGORY_2 = {
|
||||
OWNER_LICENSES: "所有ライセンス数",
|
||||
IN_USE_LICENSES: "使用中ライセンス数",
|
||||
};
|
||||
/**
|
||||
* ライセンス数推移出力機能のCSV項目で使用する日本語(ライセンス種別)
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const LICENSE_COUNT_ANALYSIS_LICENSE_TYPE = {
|
||||
TRIAL: "Trial",
|
||||
STANDARD: "Standard",
|
||||
CARD: "Card",
|
||||
SWITCH_FROM_TRIAL: "トライアルから切り替え",
|
||||
SWITCH_FROM_CARD: "カードから切り替え",
|
||||
};
|
||||
/**
|
||||
* ライセンス数推移出力機能のCSV項目で使用する日本語(役割)
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const LICENSE_COUNT_ANALYSIS_ROLE = {
|
||||
AUTHOR: "Author",
|
||||
TYPIST: "Typist",
|
||||
NONE: "None",
|
||||
UNALLOCATED: "Unallocated",
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@ import { DataSource } from "typeorm";
|
||||
import {
|
||||
getBaseData,
|
||||
getBaseDataFromDeletedAccounts,
|
||||
transferData,
|
||||
} from "../functions/analysisLicenses";
|
||||
import {
|
||||
makeTestAccount,
|
||||
@ -11,6 +12,7 @@ import {
|
||||
makeTestAccountArchive,
|
||||
createLicenseArchive,
|
||||
createLicenseAllocationHistoryArchive,
|
||||
makeTestUser,
|
||||
} from "./common/utility";
|
||||
import * as dotenv from "dotenv";
|
||||
import {
|
||||
@ -20,6 +22,9 @@ import {
|
||||
import { InvocationContext } from "@azure/functions";
|
||||
import {
|
||||
LICENSE_ALLOCATED_STATUS,
|
||||
LICENSE_COUNT_ANALYSIS_CATEGORY_1,
|
||||
LICENSE_COUNT_ANALYSIS_CATEGORY_2,
|
||||
LICENSE_COUNT_ANALYSIS_LICENSE_TYPE,
|
||||
SWITCH_FROM_TYPE,
|
||||
} from "../constants";
|
||||
describe("analysisLicenses", () => {
|
||||
@ -112,7 +117,7 @@ describe("analysisLicenses", () => {
|
||||
1,
|
||||
null,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -125,7 +130,7 @@ describe("analysisLicenses", () => {
|
||||
2,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -138,7 +143,7 @@ describe("analysisLicenses", () => {
|
||||
3,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -152,7 +157,7 @@ describe("analysisLicenses", () => {
|
||||
4,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -173,7 +178,7 @@ describe("analysisLicenses", () => {
|
||||
11,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -186,7 +191,7 @@ describe("analysisLicenses", () => {
|
||||
12,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -199,7 +204,7 @@ describe("analysisLicenses", () => {
|
||||
13,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -213,7 +218,7 @@ describe("analysisLicenses", () => {
|
||||
14,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -233,7 +238,7 @@ describe("analysisLicenses", () => {
|
||||
21,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -246,7 +251,7 @@ describe("analysisLicenses", () => {
|
||||
22,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -259,7 +264,7 @@ describe("analysisLicenses", () => {
|
||||
23,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -273,7 +278,7 @@ describe("analysisLicenses", () => {
|
||||
24,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -287,7 +292,7 @@ describe("analysisLicenses", () => {
|
||||
25,
|
||||
last2Month,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -391,10 +396,8 @@ describe("analysisLicenses", () => {
|
||||
expect(result.switchedlicensesInTargetMonth).toHaveLength(2);
|
||||
expect(result.switchedlicensesInTargetMonth[0].id).toBe(1);
|
||||
expect(result.switchedlicensesInTargetMonth[1].id).toBe(2);
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("getBaseDataFromDeletedAccounts取得情報の確認", async () => {
|
||||
if (!source) fail();
|
||||
const context = new InvocationContext();
|
||||
@ -456,7 +459,7 @@ describe("analysisLicenses", () => {
|
||||
1,
|
||||
null,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -469,7 +472,7 @@ describe("analysisLicenses", () => {
|
||||
2,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -482,7 +485,7 @@ describe("analysisLicenses", () => {
|
||||
3,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -496,7 +499,7 @@ describe("analysisLicenses", () => {
|
||||
4,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -517,7 +520,7 @@ describe("analysisLicenses", () => {
|
||||
11,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -530,7 +533,7 @@ describe("analysisLicenses", () => {
|
||||
12,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -543,7 +546,7 @@ describe("analysisLicenses", () => {
|
||||
13,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -557,7 +560,7 @@ describe("analysisLicenses", () => {
|
||||
14,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -577,7 +580,7 @@ describe("analysisLicenses", () => {
|
||||
21,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -590,7 +593,7 @@ describe("analysisLicenses", () => {
|
||||
22,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||
null,
|
||||
null,
|
||||
@ -603,7 +606,7 @@ describe("analysisLicenses", () => {
|
||||
23,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -617,7 +620,7 @@ describe("analysisLicenses", () => {
|
||||
24,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
@ -631,7 +634,7 @@ describe("analysisLicenses", () => {
|
||||
25,
|
||||
last2Month,
|
||||
account5_1.id,
|
||||
"STANDARD",
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
@ -688,7 +691,11 @@ describe("analysisLicenses", () => {
|
||||
SWITCH_FROM_TYPE.TRIAL
|
||||
);
|
||||
|
||||
const result = await getBaseDataFromDeletedAccounts(context, lastMonthYYYYMM, source);
|
||||
const result = await getBaseDataFromDeletedAccounts(
|
||||
context,
|
||||
lastMonthYYYYMM,
|
||||
source
|
||||
);
|
||||
expect(result.deletedAccountsAndUsersFromTier5).toHaveLength(2);
|
||||
expect(result.deletedAccountsAndUsersFromTier5[0].id).toBe(account5_1.id);
|
||||
expect(result.deletedAccountsAndUsersFromTier5[1].id).toBe(account5_2.id);
|
||||
@ -734,4 +741,484 @@ describe("analysisLicenses", () => {
|
||||
expect(result.deletedSwitchedlicensesInTargetMonth[1].id).toBe(2);
|
||||
});
|
||||
|
||||
it("transferDataの確認", async () => {
|
||||
// getBaseData取得情報の確認とgetBaseDataFromDeletedAccounts取得情報の確認
|
||||
if (!source) fail();
|
||||
const context = new InvocationContext();
|
||||
|
||||
const currentDate = new DateWithZeroTime();
|
||||
const expiringSoonDate = new ExpirationThresholdDate(currentDate.getTime());
|
||||
|
||||
// 現在の日付を取得
|
||||
const nowDate = new Date();
|
||||
|
||||
// 先月の日付を取得
|
||||
const lastMonth = new Date(nowDate);
|
||||
lastMonth.setMonth(nowDate.getMonth() - 1);
|
||||
const lastMonthYYYYMM = `${lastMonth.getFullYear()}${(
|
||||
lastMonth.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}`;
|
||||
|
||||
// 先々月の日付を取得
|
||||
const last2Month = new Date(nowDate);
|
||||
last2Month.setMonth(nowDate.getMonth() - 2);
|
||||
const last2MonthYYYYMM = `${last2Month.getFullYear()}${(
|
||||
last2Month.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}`;
|
||||
|
||||
// tier4とtier5のアカウント+管理者を作る
|
||||
const { account: account4, admin: admin4 } = await makeTestAccount(
|
||||
source,
|
||||
{ tier: 4 },
|
||||
{ external_id: "external_id_tier4admin" }
|
||||
);
|
||||
const { account: account5_1, admin: admin5_1_1 } = await makeTestAccount(
|
||||
source,
|
||||
{
|
||||
tier: 5,
|
||||
parent_account_id: account4.id,
|
||||
},
|
||||
{
|
||||
external_id: "external_id_tier5admin1",
|
||||
role: "author",
|
||||
}
|
||||
);
|
||||
// 第五アカウントに紐づくユーザーを作成する
|
||||
const user5_1_2 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "typist",
|
||||
});
|
||||
const user5_1_3 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "typist",
|
||||
});
|
||||
const user5_1_4 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "typist",
|
||||
});
|
||||
const user5_1_5 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "none",
|
||||
});
|
||||
const user5_1_6 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "author",
|
||||
});
|
||||
const user5_1_7 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "typist",
|
||||
});
|
||||
const user5_1_8 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "none",
|
||||
});
|
||||
const user5_1_9 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "none",
|
||||
});
|
||||
const user5_1_10 = await makeTestUser(source, {
|
||||
account_id: account5_1.id,
|
||||
role: "typist",
|
||||
});
|
||||
|
||||
// 削除ユーザを作成する
|
||||
const userArchive5_1_4 = await makeTestUserArchive(source, {
|
||||
account_id: account5_1.id,
|
||||
});
|
||||
// 第五階層以外だとヒットしないことの確認
|
||||
const userArchive4 = await makeTestUserArchive(source, {
|
||||
account_id: account4.id,
|
||||
});
|
||||
|
||||
// 所有ライセンス
|
||||
// trialLicensesCount 3件
|
||||
// normalLicensesCount 5件
|
||||
// cardLicensesCount 4件
|
||||
// usedTrialLicensesAuthorCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
1,
|
||||
null,
|
||||
account5_1.id,
|
||||
"TRIAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
admin5_1_1.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedTrialLicensesTypistCount 2件
|
||||
await createLicense(
|
||||
source,
|
||||
2,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"TRIAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_2.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
await createLicense(
|
||||
source,
|
||||
3,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"TRIAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_3.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedTrialLicensesNoneCount 0件
|
||||
// usedNormalLicensesAuthorCount 0件
|
||||
// usedNormalLicensesTypistCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
4,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_4.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedNormalLicensesNoneCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
5,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_5.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedCardLicensesAuthorCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
6,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"CARD",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_6.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedCardLicensesTypistCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
7,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"CARD",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_7.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// usedCardLicensesNoneCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
8,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"CARD",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_8.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// deleteはヒットしないことの確認
|
||||
await createLicense(
|
||||
source,
|
||||
100,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// その月に発行したライセンスを作成
|
||||
// 条件:
|
||||
// ・第五アカウント
|
||||
// ・ステータス:ALLOCATED/REUSABLE/UNALLOCATED
|
||||
// ・作成日:今日から1か月前
|
||||
// ・期限:14日後
|
||||
// currentMonthIssuedTrialLicensesCount 0件
|
||||
// currentMonthIssuedNormalLicensesCount 3件
|
||||
await createLicense(
|
||||
source,
|
||||
11,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
lastMonth
|
||||
);
|
||||
await createLicense(
|
||||
source,
|
||||
12,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
lastMonth
|
||||
);
|
||||
await createLicense(
|
||||
source,
|
||||
13,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
lastMonth
|
||||
);
|
||||
// currentMonthIssuedCardLicensesCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
14,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"CARD",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
lastMonth
|
||||
);
|
||||
// deleteはヒットしないことの確認
|
||||
await createLicense(
|
||||
source,
|
||||
101,
|
||||
expiringSoonDate,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
lastMonth
|
||||
);
|
||||
// その月に失効したライセンスを作成
|
||||
// 条件:
|
||||
// ・第五アカウント
|
||||
// ・ステータス:ALLOCATED/REUSABLE/UNALLOCATED
|
||||
// ・作成日:今日から2か月前
|
||||
// ・期限:先月
|
||||
// invalidTrialLicensesAuthorCount 0件
|
||||
// invalidTrialLicensesTypistCount 0件
|
||||
// invalidTrialLicensesNoneCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
22,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"TRIAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_9.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// invalidTrialLicensesUnallocatedCount 0件
|
||||
// invalidNormalLicensesAuthorCount 0件
|
||||
// invalidNormalLicensesTypistCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
23,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
user5_1_10.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// invalidNormalLicensesNoneCount 0件
|
||||
// invalidNormalLicensesUnallocatedCount 1件
|
||||
await createLicense(
|
||||
source,
|
||||
24,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
|
||||
// invalidCardLicensesAuthorCount 0件
|
||||
// invalidCardLicensesTypistCount 0件
|
||||
// invalidCardLicensesNoneCount 0件
|
||||
// invalidCardLicensesUnallocatedCount 0件
|
||||
// deleteはヒットしないことの確認
|
||||
await createLicense(
|
||||
source,
|
||||
102,
|
||||
lastMonth,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
// 先々月はヒットしないことの確認
|
||||
await createLicense(
|
||||
source,
|
||||
103,
|
||||
last2Month,
|
||||
account5_1.id,
|
||||
"NORMAL",
|
||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
last2Month
|
||||
);
|
||||
|
||||
// 第五階層がその月におこなったライセンス切り替え情報を作成
|
||||
// 条件:
|
||||
// ・第五アカウント
|
||||
// ・実行日時:先月
|
||||
// ・切り替えタイプ:CARD/TRIAL
|
||||
// switchedTypistLicensesAuthorCount 1件
|
||||
await createLicenseAllocationHistory(
|
||||
source,
|
||||
1,
|
||||
admin5_1_1.id,
|
||||
1,
|
||||
true,
|
||||
account5_1.id,
|
||||
lastMonth,
|
||||
SWITCH_FROM_TYPE.TRIAL
|
||||
);
|
||||
// switchedTypistLicensesTypistCount 0件
|
||||
// switchedTypistLicensesNoneCount 0件
|
||||
// switchedCardLicensesAuthorCount 1件
|
||||
await createLicenseAllocationHistory(
|
||||
source,
|
||||
2,
|
||||
admin5_1_1.id,
|
||||
1,
|
||||
true,
|
||||
account5_1.id,
|
||||
lastMonth,
|
||||
SWITCH_FROM_TYPE.CARD
|
||||
);
|
||||
// switchedCardLicensesTypistCount 0件
|
||||
// switchedCardLicensesNoneCount 0件
|
||||
// SWITCH_FROM_TYPE.NONEではヒットしないことの確認
|
||||
await createLicenseAllocationHistory(
|
||||
source,
|
||||
3,
|
||||
admin5_1_1.id,
|
||||
1,
|
||||
true,
|
||||
account5_1.id,
|
||||
lastMonth,
|
||||
SWITCH_FROM_TYPE.NONE
|
||||
);
|
||||
// 先々月の登録ではヒットしないことの確認
|
||||
await createLicenseAllocationHistory(
|
||||
source,
|
||||
4,
|
||||
admin5_1_1.id,
|
||||
1,
|
||||
true,
|
||||
account5_1.id,
|
||||
last2Month,
|
||||
SWITCH_FROM_TYPE.TRIAL
|
||||
);
|
||||
|
||||
const result = await getBaseData(context, lastMonthYYYYMM, source);
|
||||
const result_D = await getBaseDataFromDeletedAccounts(
|
||||
context,
|
||||
lastMonthYYYYMM,
|
||||
source
|
||||
);
|
||||
const transferDataResult = await transferData(
|
||||
context,
|
||||
result,
|
||||
result_D,
|
||||
lastMonthYYYYMM
|
||||
);
|
||||
// ヘッダー行
|
||||
// "アカウント", "対象年月", "カテゴリー1", "カテゴリー2", "ライセンス種別", "役割", "数量"
|
||||
expect(transferDataResult.outputDataUS[0]).toEqual('"アカウント",');
|
||||
expect(transferDataResult.outputDataUS[1]).toEqual('"対象年月",');
|
||||
expect(transferDataResult.outputDataUS[2]).toEqual(`"カテゴリー1",`);
|
||||
expect(transferDataResult.outputDataUS[3]).toEqual(`"カテゴリー2",`);
|
||||
expect(transferDataResult.outputDataUS[4]).toEqual(`"ライセンス種別",`);
|
||||
expect(transferDataResult.outputDataUS[5]).toEqual(`"役割",`);
|
||||
expect(transferDataResult.outputDataUS[6]).toEqual(`"数量"` + "\r\n");
|
||||
// データ行
|
||||
// "アカウント", "対象年月", "カテゴリー1", "カテゴリー2", "ライセンス種別", "役割", "数量"
|
||||
// 1行目だけ確認する
|
||||
expect(transferDataResult.outputDataUS[7]).toEqual(
|
||||
`"${account5_1.company_name}",`
|
||||
);
|
||||
expect(transferDataResult.outputDataUS[8]).toEqual(`"${lastMonthYYYYMM}",`);
|
||||
expect(transferDataResult.outputDataUS[9]).toEqual(
|
||||
`"${LICENSE_COUNT_ANALYSIS_CATEGORY_1.VALID_LICENSES}",`
|
||||
);
|
||||
expect(transferDataResult.outputDataUS[10]).toEqual(
|
||||
`"${LICENSE_COUNT_ANALYSIS_CATEGORY_2.OWNER_LICENSES}",`
|
||||
);
|
||||
expect(transferDataResult.outputDataUS[11]).toEqual(
|
||||
`"${LICENSE_COUNT_ANALYSIS_LICENSE_TYPE.TRIAL}",`
|
||||
);
|
||||
expect(transferDataResult.outputDataUS[12]).toEqual(`"",`);
|
||||
expect(transferDataResult.outputDataUS[13]).toEqual(`"3"` + "\r\n");
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
License,
|
||||
LicenseAllocationHistory,
|
||||
LicenseArchive,
|
||||
LicenseAllocationHistoryArchive
|
||||
LicenseAllocationHistoryArchive,
|
||||
} from "../../entity/license.entity";
|
||||
|
||||
type InitialTestDBState = {
|
||||
@ -131,7 +131,7 @@ export const makeTestAccount = async (
|
||||
const { identifiers } = await datasource.getRepository(User).insert({
|
||||
external_id: d?.external_id ?? uuidv4(),
|
||||
account_id: accountId,
|
||||
role: d?.role ?? "admin none",
|
||||
role: d?.role ?? "none",
|
||||
author_id: d?.author_id ?? undefined,
|
||||
accepted_eula_version: d?.accepted_eula_version ?? "1.0",
|
||||
accepted_dpa_version: d?.accepted_dpa_version ?? "1.0",
|
||||
@ -224,7 +224,7 @@ export const createLicenseAllocationHistory = async (
|
||||
is_allocated: boolean,
|
||||
account_id: number,
|
||||
executed_at: Date,
|
||||
switch_from_type: string,
|
||||
switch_from_type: string
|
||||
): Promise<void> => {
|
||||
const { identifiers } = await datasource
|
||||
.getRepository(LicenseAllocationHistory)
|
||||
@ -316,8 +316,6 @@ export const makeTestUserArchive = async (
|
||||
return userArchive;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* テスト ユーティリティ: 指定したプロパティを上書きしたアカウントとその管理者ユーザーを作成する
|
||||
* @param dataSource データソース
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user