Merged PR 668: 有効期限>翌日になっているのを>当日に修正する
## 概要 [Task3421: 有効期限>翌日になっているのを>当日に修正する](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3421) - 有効期限>翌日になっているのを>当日に修正 翌日が有効期限のものは割り当ての対象とする。 念のためテストケースを追加 ## レビューポイント - とくになし ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
7f8e2d5411
commit
0a9f125d76
@ -13,7 +13,6 @@ import {
|
|||||||
} from "../constants";
|
} from "../constants";
|
||||||
import {
|
import {
|
||||||
DateWithDayEndTime,
|
DateWithDayEndTime,
|
||||||
DateWithNextDayEndTime,
|
|
||||||
DateWithZeroTime,
|
DateWithZeroTime,
|
||||||
NewAllocatedLicenseExpirationDate,
|
NewAllocatedLicenseExpirationDate,
|
||||||
} from "../common/types/types";
|
} from "../common/types/types";
|
||||||
@ -215,7 +214,6 @@ export async function getAutoAllocatableLicense(
|
|||||||
): Promise<License | undefined> {
|
): Promise<License | undefined> {
|
||||||
try {
|
try {
|
||||||
context.log("[IN]getAutoAllocatableLicense");
|
context.log("[IN]getAutoAllocatableLicense");
|
||||||
const currentNextDateTime = new DateWithNextDayEndTime(currentDateEndTime);
|
|
||||||
// 割り当て可能なライセンスを取得
|
// 割り当て可能なライセンスを取得
|
||||||
const license = await licenseRepository.findOne({
|
const license = await licenseRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
@ -224,7 +222,7 @@ export async function getAutoAllocatableLicense(
|
|||||||
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||||
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||||
]),
|
]),
|
||||||
expiry_date: MoreThan(currentNextDateTime) || null,
|
expiry_date: MoreThan(currentDateEndTime) || null,
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
expiry_date: "ASC",
|
expiry_date: "ASC",
|
||||||
|
|||||||
@ -81,6 +81,16 @@ describe("licenseAutoAllocation", () => {
|
|||||||
role: `${USER_ROLES.NONE}`,
|
role: `${USER_ROLES.NONE}`,
|
||||||
auto_renew: false,
|
auto_renew: false,
|
||||||
});
|
});
|
||||||
|
// 更新対象のユーザー(Author二人目)
|
||||||
|
const user6 = await makeTestUser(source, {
|
||||||
|
account_id: account1.account.id,
|
||||||
|
role: `${USER_ROLES.AUTHOR}`,
|
||||||
|
});
|
||||||
|
// 更新対象のユーザー(ただしライセンスが足りない)
|
||||||
|
const user7 = await makeTestUser(source, {
|
||||||
|
account_id: account1.account.id,
|
||||||
|
role: `${USER_ROLES.NONE}`,
|
||||||
|
});
|
||||||
|
|
||||||
// 割り当て済みで有効期限が本日のライセンス
|
// 割り当て済みで有効期限が本日のライセンス
|
||||||
await createLicense(
|
await createLicense(
|
||||||
@ -143,6 +153,30 @@ describe("licenseAutoAllocation", () => {
|
|||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
await createLicense(
|
||||||
|
source,
|
||||||
|
6,
|
||||||
|
currentDateEndTime,
|
||||||
|
account1.account.id,
|
||||||
|
LICENSE_TYPE.CARD,
|
||||||
|
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||||
|
user6.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
await createLicense(
|
||||||
|
source,
|
||||||
|
7,
|
||||||
|
currentDateEndTime,
|
||||||
|
account1.account.id,
|
||||||
|
LICENSE_TYPE.CARD,
|
||||||
|
LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||||
|
user7.id,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// 割り当て済みの更新対象ではないライセンス
|
// 割り当て済みの更新対象ではないライセンス
|
||||||
const nextDate = new Date();
|
const nextDate = new Date();
|
||||||
@ -163,9 +197,9 @@ describe("licenseAutoAllocation", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 有効期限が先の未割当ライセンスを作成
|
// 有効期限が先の未割当ライセンスを作成
|
||||||
// idが100,101のものは有効期限が当日、翌日なので自動割り当て対象外
|
// idが100のものは有効期限が当日なので自動割り当て対象外
|
||||||
// idが102のものから割り当てられる
|
// idが101のものから割り当てられる
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setDate(date.getDate() + i);
|
date.setDate(date.getDate() + i);
|
||||||
date.setHours(23, 59, 59); // 時分秒を"23:59:59"に固定
|
date.setHours(23, 59, 59); // 時分秒を"23:59:59"に固定
|
||||||
@ -207,6 +241,8 @@ describe("licenseAutoAllocation", () => {
|
|||||||
const user3Allocated = await selectLicenseByAllocatedUser(source, user3.id);
|
const user3Allocated = await selectLicenseByAllocatedUser(source, user3.id);
|
||||||
const user4Allocated = await selectLicenseByAllocatedUser(source, user4.id);
|
const user4Allocated = await selectLicenseByAllocatedUser(source, user4.id);
|
||||||
const user5Allocated = await selectLicenseByAllocatedUser(source, user5.id);
|
const user5Allocated = await selectLicenseByAllocatedUser(source, user5.id);
|
||||||
|
const user6Allocated = await selectLicenseByAllocatedUser(source, user6.id);
|
||||||
|
const user7Allocated = await selectLicenseByAllocatedUser(source, user7.id);
|
||||||
const admin2Allocated = await selectLicenseByAllocatedUser(
|
const admin2Allocated = await selectLicenseByAllocatedUser(
|
||||||
source,
|
source,
|
||||||
account2.admin.id
|
account2.admin.id
|
||||||
@ -218,12 +254,16 @@ describe("licenseAutoAllocation", () => {
|
|||||||
);
|
);
|
||||||
// Author、Typist、Noneの優先順位で割り当てられていることを確認
|
// Author、Typist、Noneの優先順位で割り当てられていることを確認
|
||||||
expect(user1Allocated.license?.id).toBe(104);
|
expect(user1Allocated.license?.id).toBe(104);
|
||||||
expect(user2Allocated.license?.id).toBe(102);
|
expect(user2Allocated.license?.id).toBe(101);
|
||||||
expect(user3Allocated.license?.id).toBe(103);
|
expect(user3Allocated.license?.id).toBe(103);
|
||||||
// 有効期限がまだあるので、ライセンスが更新されていないことを確認
|
// 有効期限がまだあるので、ライセンスが更新されていないことを確認
|
||||||
expect(user4Allocated.license?.id).toBe(4);
|
expect(user4Allocated.license?.id).toBe(4);
|
||||||
// auto_renewがfalseなので、ライセンスが更新されていないことを確認
|
// auto_renewがfalseなので、ライセンスが更新されていないことを確認
|
||||||
expect(user5Allocated.license?.id).toBe(5);
|
expect(user5Allocated.license?.id).toBe(5);
|
||||||
|
// 複数Authorがいる場合、それぞれに割り当てられていることを確認
|
||||||
|
expect(user6Allocated.license?.id).toBe(102);
|
||||||
|
// ライセンスが足りない場合、ライセンスが更新されていないことを確認
|
||||||
|
expect(user7Allocated.license?.id).toBe(7);
|
||||||
// 複数アカウント分の処理が正常に行われていることの確認
|
// 複数アカウント分の処理が正常に行われていることの確認
|
||||||
expect(admin2Allocated.license?.id).toBe(200);
|
expect(admin2Allocated.license?.id).toBe(200);
|
||||||
|
|
||||||
@ -369,8 +409,8 @@ describe("licenseAutoAllocation", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 有効期限が先の未割当ライセンスを作成
|
// 有効期限が先の未割当ライセンスを作成
|
||||||
// idが100,101のものは有効期限が当日、翌日なので自動割り当て対象外
|
// idが100のものは有効期限が当日なので自動割り当て対象外
|
||||||
// idが102のものから割り当てられる
|
// idが101のものから割り当てられる
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setDate(dateSeptember22.getDate() + i);
|
date.setDate(dateSeptember22.getDate() + i);
|
||||||
@ -420,12 +460,12 @@ describe("licenseAutoAllocation", () => {
|
|||||||
const licenseAllocationHistory = await selectLicenseAllocationHistory(
|
const licenseAllocationHistory = await selectLicenseAllocationHistory(
|
||||||
source,
|
source,
|
||||||
user1.id,
|
user1.id,
|
||||||
104
|
103
|
||||||
);
|
);
|
||||||
// Author、Typist、Noneの優先順位で割り当てられていることを確認
|
// Author、Typist、Noneの優先順位で割り当てられていることを確認
|
||||||
expect(user1Allocated.license?.id).toBe(104);
|
expect(user1Allocated.license?.id).toBe(103);
|
||||||
expect(user2Allocated.license?.id).toBe(102);
|
expect(user2Allocated.license?.id).toBe(101);
|
||||||
expect(user3Allocated.license?.id).toBe(103);
|
expect(user3Allocated.license?.id).toBe(102);
|
||||||
// 有効期限がまだあるので、ライセンスが更新されていないことを確認
|
// 有効期限がまだあるので、ライセンスが更新されていないことを確認
|
||||||
expect(user4Allocated.license?.id).toBe(4);
|
expect(user4Allocated.license?.id).toBe(4);
|
||||||
// auto_renewがfalseなので、ライセンスが更新されていないことを確認
|
// auto_renewがfalseなので、ライセンスが更新されていないことを確認
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user