diff --git a/src/apps/入金予定結果/index.tsx b/src/apps/入金予定結果/index.tsx index 0cabd13..64ab261 100644 --- a/src/apps/入金予定結果/index.tsx +++ b/src/apps/入金予定結果/index.tsx @@ -19,6 +19,15 @@ import Swal from "sweetalert2"; const client = new KintoneRestAPIClient(); +const 残金設定 = (record: 入金予定結果) => { + record[入金予定結果フィールド名.残金].value = (() => { + const amount = + Number(record[入金予定結果フィールド名.支払予定金額].value ?? 0) - + Number(record[入金予定結果フィールド名.入金額].value ?? 0); + return String(amount); + })(); +}; + const 承認メール送信 = (record: 入金予定結果) => { return sendEmail(EmailID.申込承認, { season_ticket_contract_entry_record_no: Number( @@ -159,10 +168,16 @@ const setData = (event: any, targets: string[]) => { kintone.events.on( KintoneEvent.追加.レコード追加画面を表示した後, eventHnalder(async (event) => { + const record = event.record as 入金予定結果; setData(event, [ 入金予定結果フィールド名.車室情報管理レコード番号, 入金予定結果フィールド名.初回振り込み関連申込レコード番号, + 入金予定結果フィールド名.支払予定金額, + 入金予定結果フィールド名.支払種別, + 入金予定結果フィールド名.支払方法, ]); + + 残金設定(record); return event; }) ); @@ -212,4 +227,26 @@ const setData = (event: any, targets: string[]) => { } }) ); + + kintone.events.on( + [ + KintoneEvent.追加.フィールドの値を変更したとき( + 入金予定結果フィールド名.支払予定金額 + ), + KintoneEvent.追加.フィールドの値を変更したとき( + 入金予定結果フィールド名.入金額 + ), + KintoneEvent.編集.フィールドの値を変更したとき( + 入金予定結果フィールド名.支払予定金額 + ), + KintoneEvent.編集.フィールドの値を変更したとき( + 入金予定結果フィールド名.入金額 + ), + ], + (event) => { + const record = event.record as 入金予定結果; + 残金設定(record); + return event; + } + ); })(); diff --git a/src/apps/各種申請/index.tsx b/src/apps/各種申請/index.tsx index 33a4af2..bbcff38 100644 --- a/src/apps/各種申請/index.tsx +++ b/src/apps/各種申請/index.tsx @@ -16,11 +16,18 @@ import { 状況Dropdown, 申請種別Dropdown, 申請詳細グループ, + 車庫証明支払方法Dropdown, } from "@/types/各種申請"; import { 車室情報管理フィールド名 } from "@/types/車室情報管理"; import { 顧客マスタフィールド名 } from "@/types/顧客マスタ"; import { setup } from ".."; import { get } from "lodash"; +import { getCreateUrl } from "@/rest-api/url"; +import { + 入金予定結果フィールド名, + 支払方法Dropdown, + 支払種別Dropdown, +} from "@/types/入金予定結果"; const 各種申請完了 = (record: 各種申請) => { bulkRequest.update({ @@ -220,6 +227,40 @@ const 車両番号変更承認ボタン = (record: 各種申請) => { ); } }; +const 車庫証明発行手数料入金予定作成 = (record: 各種申請) => { + if (record.申請種別.value === 申請種別Dropdown.車庫証明発行申請) { + setHeaderButton( + "車庫証明発行手数料入金予定作成", + apptemplate(async () => { + const param: any = { + [入金予定結果フィールド名.支払予定金額]: "3000", + [入金予定結果フィールド名.車室情報管理レコード番号]: record.$id.value, + [入金予定結果フィールド名.支払種別]: 支払種別Dropdown.事務手数料, + }; + param[入金予定結果フィールド名.支払方法] = (() => { + if ( + record.車庫証明発行申請_支払方法.value === + 車庫証明支払方法Dropdown.口座引落 + ) { + return 支払方法Dropdown.SMBC口座振替; + } + if ( + record.車庫証明発行申請_支払方法.value === + 車庫証明支払方法Dropdown.お振込 + ) { + return 支払方法Dropdown.振込; + } + return ""; + })(); + const url = getCreateUrl( + AppID.入金予定結果, + new URLSearchParams(param) + ); + window.open(url, "_blank"); + }) + ); + } +}; setup(() => { kintone.events.on( @@ -233,6 +274,7 @@ setup(() => { 解約承認ボタン(record); 利用者情報変更承認ボタン(record); 車両番号変更承認ボタン(record); + 車庫証明発行手数料入金予定作成(record); }) ); diff --git a/src/types/入金予定結果.ts b/src/types/入金予定結果.ts index 403186e..5a5d75e 100644 --- a/src/types/入金予定結果.ts +++ b/src/types/入金予定結果.ts @@ -13,6 +13,8 @@ const F = { 入金額: "appropriation_amount", 残金: "remaining_amount", 初回振り込み関連申込レコード番号: "first_payment_entry_record_no", + 支払方法: "payment_method", + 支払種別: "payment_type", } as const; export const 支払種別Dropdown = { @@ -26,6 +28,16 @@ export const 支払種別Dropdown = { export type 支払種別Dropdown = (typeof 支払種別Dropdown)[keyof typeof 支払種別Dropdown]; +export const 支払方法Dropdown = { + SMBC口座振替: "SMBC口座振替", + 振込: "振込", + コンビニ: "コンビニ", + 現金: "現金", + クレジットカード: "クレジットカード", +} as const; +export type 支払方法Dropdown = + (typeof 支払方法Dropdown)[keyof typeof 支払方法Dropdown]; + export const 入金予定結果フィールド名 = F; export type 入金予定結果 = AppRecord & { @@ -37,13 +49,13 @@ export type 入金予定結果 = AppRecord & { [F.支払対象_利用_年]: KintoneRecordField.SingleLineText; [F.支払対象_利用_月]: KintoneRecordField.SingleLineText; [F.入金額]: KintoneRecordField.Number; - payment_type: KintoneRecordField.Dropdown; + [F.支払種別]: KintoneRecordField.Dropdown; customer_name_kana: KintoneRecordField.SingleLineText; [F.支払予定金額]: KintoneRecordField.Number; [F.支払対象_利用_月間数]: KintoneRecordField.SingleLineText; customer_name: KintoneRecordField.SingleLineText; parking_name: KintoneRecordField.SingleLineText; customer_code: KintoneRecordField.Number; - payment_method: KintoneRecordField.Dropdown; + [F.支払方法]: KintoneRecordField.Dropdown; [F.初回振り込み関連申込レコード番号]: KintoneRecordField.Number; }; diff --git a/src/types/各種申請.ts b/src/types/各種申請.ts index c33bd10..4cb533d 100644 --- a/src/types/各種申請.ts +++ b/src/types/各種申請.ts @@ -27,6 +27,13 @@ export const 申請種別Dropdown = { export type 申請種別Dropdown = (typeof 申請種別Dropdown)[keyof typeof 申請種別Dropdown]; +export const 車庫証明支払方法Dropdown = { + 口座引落: "口座引落", + お振込: "お振込", +} as const; +export type 車庫証明支払方法Dropdown = + (typeof 車庫証明支払方法Dropdown)[keyof typeof 車庫証明支払方法Dropdown]; + export const 申請詳細グループ = { [申請種別Dropdown.解約申請]: "解約申請", [申請種別Dropdown.車庫証明発行申請]: "車庫証明発行申請",