From 1c2a705255016853d711d0edf86b33a864b5ed7d Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Fri, 15 Dec 2023 11:01:11 +0900 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8B=95=E6=89=BF=E8=AA=8D=E3=82=92?= =?UTF-8?q?=E6=9C=AA=E6=9D=A5=E3=81=AE=E8=A7=A3=E7=B4=84=E5=88=86=E3=82=92?= =?UTF-8?q?=E8=80=83=E6=85=AE=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/各種申請/index.tsx | 7 +++++++ src/apps/定期申込予約/自動承認.ts | 5 ++++- src/common/app-template.ts | 2 +- src/rest-api/車室契約情報.ts | 10 +++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/apps/各種申請/index.tsx b/src/apps/各種申請/index.tsx index 393597a..bd7a97d 100644 --- a/src/apps/各種申請/index.tsx +++ b/src/apps/各種申請/index.tsx @@ -1,6 +1,7 @@ import { AppID } from "@/common/appids"; import { setHeaderButton } from "@/common/header-button"; import { makeRecordData } from "@/common/rest-api-client"; +import { 契約状況同期 } from "@/logic/契約状況同期"; import { ConfirmDialog, ErrorDialog, @@ -8,6 +9,7 @@ import { showLoadingDialog, } from "@/middleware/swal"; import { EmailID, sendEmail } from "@/mypage/メール"; +import { get車室契約情報 } from "@/rest-api/車室契約情報"; import { get顧客マスタ } from "@/rest-api/顧客マスタ"; import { 各種申請, @@ -94,6 +96,8 @@ const getCallBack口座変更申請承認 = (record: 各種申請) => { }; const 解約申請承認 = async (record: 各種申請) => { + const 契約 = await get車室契約情報(record.契約情報.value); + // 車室契約情報への反映 await client.record.updateRecord({ app: AppID.車室契約情報, @@ -103,6 +107,9 @@ const 解約申請承認 = async (record: 各種申請) => { }), }); + // 契約情報の同期処理 + await 契約状況同期(契約.駐車場名.value, Number(契約.車室番号.value)); + // 申請の完了 await 各種申請完了(record); diff --git a/src/apps/定期申込予約/自動承認.ts b/src/apps/定期申込予約/自動承認.ts index edbab47..478e14e 100644 --- a/src/apps/定期申込予約/自動承認.ts +++ b/src/apps/定期申込予約/自動承認.ts @@ -26,6 +26,7 @@ import { 車室情報2 } from "@/types/車室情報2"; import { 顧客マスタフィールド名 } from "@/types/顧客マスタ"; import { sprintf } from "sprintf"; import { CancelError, Message } from "@/exception"; +import { dateParse, now } from "@/common/datetime"; export class 申込 { private 定期申込予約: 定期申込予約; @@ -102,9 +103,11 @@ export class 申込 { if (!this.定期申込予約.駐車場.value) { throw new Message("駐車場名の設定をしてください"); } + + const 基準日 = dateParse(this.定期申込予約.利用開始希望日.value) ?? now(); this.契約一覧 = await get車室契約情報一覧({ 駐車場名: this.定期申込予約.駐車場.value, - 契約中のみ: true, + 契約中のみ: 基準日, }); } private async 自動承認グループ取得() { diff --git a/src/common/app-template.ts b/src/common/app-template.ts index 9e27644..82a56d1 100644 --- a/src/common/app-template.ts +++ b/src/common/app-template.ts @@ -4,7 +4,7 @@ import { ErrorDialog } from "@/middleware/swal"; export const apptemplate = (callback: () => Promise) => { return async () => { try { - const ret = await callback(); + await callback(); } catch (e) { if (e instanceof CancelError) { console.log("canceled"); diff --git a/src/rest-api/車室契約情報.ts b/src/rest-api/車室契約情報.ts index e295fed..d502f72 100644 --- a/src/rest-api/車室契約情報.ts +++ b/src/rest-api/車室契約情報.ts @@ -7,7 +7,7 @@ import { QueryBuilder } from "./query"; const client = new KintoneRestAPIClient(); export const get車室契約情報 = async ( - レコード番号: number + レコード番号: number | string ): Promise<車室契約情報> => { const { record } = await client.record.getRecord<車室契約情報>({ app: AppID.車室契約情報, @@ -20,7 +20,7 @@ export const get車室契約情報 = async ( type get車室契約情報一覧オプション = { 駐車場名?: string; 車室番号?: number | string; - 契約中のみ?: boolean; + 契約中のみ?: Date; }; export const get車室契約情報一覧 = async ({ 駐車場名, @@ -35,9 +35,9 @@ export const get車室契約情報一覧 = async ({ if (車室番号) { builder.where(車室契約情報フィールド名.車室番号, 車室番号); } - if (契約中のみ) { - const todayStr = formatDateStr(now()); - builder.where(車室契約情報フィールド名.解約日, todayStr, ">"); + if (契約中のみ instanceof Date) { + const 基準日文字列 = formatDateStr(契約中のみ); + builder.where(車室契約情報フィールド名.解約日, 基準日文字列, ">"); } const record = await client.record.getAllRecords<車室契約情報>({