| @@ -22,7 +22,7 @@ export type AppReceiptIssuingOrder = { | |||||
| // 領収証確定 | // 領収証確定 | ||||
| export type ConfirmRequest = { | export type ConfirmRequest = { | ||||
| id: string; | |||||
| access_token: string; | |||||
| receipt_name: string; | receipt_name: string; | ||||
| timestamp: string; | timestamp: string; | ||||
| }; | }; | ||||
| @@ -15,6 +15,11 @@ export type HTAdjustData = { | |||||
| parking_management_code: string; | parking_management_code: string; | ||||
| adjust_seq_no: number; | adjust_seq_no: number; | ||||
| adjust_datetime: string; | adjust_datetime: string; | ||||
| tax_charge: number; | |||||
| putin_datetime: string; | |||||
| adjust_type: string; | |||||
| amount: number; | |||||
| }; | }; | ||||
| export type HTCustomersResponse = { | export type HTCustomersResponse = { | ||||
| @@ -53,6 +58,8 @@ export const getHTParkings = async (data: HTParkingsRequest) => { | |||||
| export type HTAdjustDataRequest = { | export type HTAdjustDataRequest = { | ||||
| customer_code: string; | customer_code: string; | ||||
| parking_management_code: string; | |||||
| adjust_seq_no: string; | |||||
| }; | }; | ||||
| export type HTAdjustDataResponse = { | export type HTAdjustDataResponse = { | ||||
| @@ -8,22 +8,7 @@ import { | |||||
| } from "api"; | } from "api"; | ||||
| import { ReceiptIssuingOrder } from "api/receipt-issuing-order"; | import { ReceiptIssuingOrder } from "api/receipt-issuing-order"; | ||||
| import { getUrl } from "api/url"; | import { getUrl } from "api/url"; | ||||
| export type HTCustomer = { | |||||
| customer_code: string; | |||||
| name: string; | |||||
| }; | |||||
| export type HTParking = { | |||||
| customer_code: string; | |||||
| parking_management_code: string; | |||||
| name: string; | |||||
| }; | |||||
| export type HTAdjustData = { | |||||
| customer_code: string; | |||||
| parking_management_code: string; | |||||
| adjust_seq_no: number; | |||||
| adjust_datetime: string; | |||||
| }; | |||||
| import { HTCustomer } from "."; | |||||
| export type CreateReceiptIssuingOrderRequest = { | export type CreateReceiptIssuingOrderRequest = { | ||||
| customer_code: string; | customer_code: string; | ||||
| @@ -21,7 +21,7 @@ const schema = Yup.object().shape({ | |||||
| }); | }); | ||||
| export default function useReceiptIssuingOrderConfirm() { | export default function useReceiptIssuingOrderConfirm() { | ||||
| const { receiptIssuingOrder: order, fetch } = useApp(); | |||||
| const { receiptIssuingOrder: order, fetch, token } = useApp(); | |||||
| const { success, error } = useSnackbarCustom(); | const { success, error } = useSnackbarCustom(); | ||||
| const { setShowBackDrop } = useBackDrop(); | const { setShowBackDrop } = useBackDrop(); | ||||
| @@ -46,7 +46,7 @@ export default function useReceiptIssuingOrderConfirm() { | |||||
| onAgree: () => { | onAgree: () => { | ||||
| if (!order) return; | if (!order) return; | ||||
| api.callAPI({ | api.callAPI({ | ||||
| id: order.id, | |||||
| access_token: token, | |||||
| receipt_name: receiptName, | receipt_name: receiptName, | ||||
| timestamp: order.updated_at, | timestamp: order.updated_at, | ||||
| }); | }); | ||||
| @@ -11,6 +11,7 @@ import { createReceiptIssuingOrder } from "api/custom/hello-techno/receipt-issui | |||||
| import useSnackbarCustom from "hooks/useSnackbarCustom"; | import useSnackbarCustom from "hooks/useSnackbarCustom"; | ||||
| import useBackDrop from "hooks/useBackDrop"; | import useBackDrop from "hooks/useBackDrop"; | ||||
| import { getValue } from "components/hook-form/RHFAutoComplete"; | import { getValue } from "components/hook-form/RHFAutoComplete"; | ||||
| import { getHTAdjustData } from "api/custom/hello-techno"; | |||||
| export default function ReceiptIssuingOrderCreate() { | export default function ReceiptIssuingOrderCreate() { | ||||
| const { setHeaderTitle, setTabs } = useDashboard( | const { setHeaderTitle, setTabs } = useDashboard( | ||||
| @@ -59,9 +60,32 @@ export default function ReceiptIssuingOrderCreate() { | |||||
| }; | }; | ||||
| }; | }; | ||||
| const adjustDataAPI = useAPICall({ | |||||
| apiMethod: getHTAdjustData, | |||||
| backDrop: true, | |||||
| onSuccess: ({ data }) => { | |||||
| inputReceiptStep.setAdjustData(data); | |||||
| setMode("input_receipt"); | |||||
| }, | |||||
| onFailed: () => { | |||||
| error("精算履歴が存在しません"); | |||||
| }, | |||||
| }); | |||||
| const selectParkingStep = useSelectParkingStep({ | const selectParkingStep = useSelectParkingStep({ | ||||
| onNext: () => { | onNext: () => { | ||||
| setMode("input_receipt"); | |||||
| const { customerCode, parkingManagementCode, adjustSeqNo } = | |||||
| getFormData(); | |||||
| if (adjustSeqNo) { | |||||
| adjustDataAPI.callAPI({ | |||||
| customer_code: getValue(customerCode), | |||||
| parking_management_code: getValue(parkingManagementCode), | |||||
| adjust_seq_no: adjustSeqNo, | |||||
| }); | |||||
| } else { | |||||
| inputReceiptStep.setAdjustData(null); | |||||
| setMode("input_receipt"); | |||||
| } | |||||
| }, | }, | ||||
| }); | }); | ||||
| @@ -79,7 +79,7 @@ export default function ReceiptIssuingOrderDetail() { | |||||
| { | { | ||||
| title: "担当者", | title: "担当者", | ||||
| value: order.handler_name, | value: order.handler_name, | ||||
| end: <Button sx={{ minWidth: 80 }}>担当変更</Button>, | |||||
| // end: <Button sx={{ minWidth: 80 }}>担当変更</Button>, | |||||
| }, | }, | ||||
| { title: "SMS送信先", value: order.sms_phone_number }, | { title: "SMS送信先", value: order.sms_phone_number }, | ||||
| { title: "依頼日", value: formatDateStr(order.order_datetime) }, | { title: "依頼日", value: formatDateStr(order.order_datetime) }, | ||||
| @@ -1,6 +1,7 @@ | |||||
| import { yupResolver } from "@hookform/resolvers/yup"; | import { yupResolver } from "@hookform/resolvers/yup"; | ||||
| import { Box, Button, Stack, TextField, Typography } from "@mui/material"; | import { Box, Button, Stack, TextField, Typography } from "@mui/material"; | ||||
| import { HasChildren } from "@types"; | import { HasChildren } from "@types"; | ||||
| import { HTAdjustData, getHTAdjustData } from "api/custom/hello-techno"; | |||||
| import { | import { | ||||
| FormProvider, | FormProvider, | ||||
| RHFAutoComplete, | RHFAutoComplete, | ||||
| @@ -12,8 +13,9 @@ import { | |||||
| getValue, | getValue, | ||||
| } from "components/hook-form/RHFAutoComplete"; | } from "components/hook-form/RHFAutoComplete"; | ||||
| import RHFDatePicker from "components/hook-form/RHFDatePicker"; | import RHFDatePicker from "components/hook-form/RHFDatePicker"; | ||||
| import { useState } from "react"; | |||||
| import { useEffect, useMemo, useState } from "react"; | |||||
| import { useForm } from "react-hook-form"; | import { useForm } from "react-hook-form"; | ||||
| import { dateTimeParse } from "utils/datetime"; | |||||
| import * as Yup from "yup"; | import * as Yup from "yup"; | ||||
| type AreaBoxProps = { | type AreaBoxProps = { | ||||
| @@ -39,7 +41,7 @@ type Props = { | |||||
| onPrev?: VoidFunction; | onPrev?: VoidFunction; | ||||
| }; | }; | ||||
| export default function useInputReceiptStep({ onNext, onPrev }: Props) { | export default function useInputReceiptStep({ onNext, onPrev }: Props) { | ||||
| const [adjustSeqNo, setAdjustSeqNo] = useState(""); | |||||
| const [adjustData, _setAdjustData] = useState<HTAdjustData | null>(null); | |||||
| const form = useForm<FormProps>({ | const form = useForm<FormProps>({ | ||||
| defaultValues: { | defaultValues: { | ||||
| @@ -71,19 +73,30 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { | |||||
| } | } | ||||
| }; | }; | ||||
| const setAdjustData = (data: HTAdjustData | null) => { | |||||
| _setAdjustData(data); | |||||
| }; | |||||
| const readOnly = useMemo(() => { | |||||
| return adjustData !== null; | |||||
| }, [adjustData]); | |||||
| const element = ( | const element = ( | ||||
| <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> | <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> | ||||
| <Stack spacing={2} sx={{ p: 1, m: 1 }}> | <Stack spacing={2} sx={{ p: 1, m: 1 }}> | ||||
| <AreaBox title="利用日"> | <AreaBox title="利用日"> | ||||
| <RHFDatePicker name="date" size="small" /> | |||||
| <RHFDatePicker name="date" size="small" readOnly={readOnly} /> | |||||
| </AreaBox> | </AreaBox> | ||||
| <AreaBox title="金額"> | <AreaBox title="金額"> | ||||
| <RHFTextField | <RHFTextField | ||||
| type="number" | type="number" | ||||
| name="amount" | name="amount" | ||||
| size="small" | size="small" | ||||
| InputProps={{ endAdornment: <div>円</div> }} | |||||
| InputProps={{ | |||||
| endAdornment: <div style={{ color: "black !important" }}>円</div>, | |||||
| }} | |||||
| sx={{ maxWidth: 150 }} | sx={{ maxWidth: 150 }} | ||||
| readOnly={readOnly} | |||||
| /> | /> | ||||
| </AreaBox> | </AreaBox> | ||||
| <AreaBox title="メモ"> | <AreaBox title="メモ"> | ||||
| @@ -100,6 +113,20 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { | |||||
| </Stack> | </Stack> | ||||
| </FormProvider> | </FormProvider> | ||||
| ); | ); | ||||
| useEffect(() => { | |||||
| if (adjustData) { | |||||
| form.setValue("amount", String(adjustData.amount)); | |||||
| form.setValue("date", dateTimeParse(adjustData.adjust_datetime)); | |||||
| } else { | |||||
| form.setValue("amount", ""); | |||||
| form.setValue("date", null); | |||||
| } | |||||
| }, [adjustData]); | |||||
| return { element, values: form.getValues, setValue: form.setValue }; | |||||
| return { | |||||
| element, | |||||
| values: form.getValues, | |||||
| setValue: form.setValue, | |||||
| setAdjustData, | |||||
| }; | |||||
| } | } | ||||
| @@ -10,7 +10,6 @@ import { | |||||
| import { | import { | ||||
| AutoCompleteOption, | AutoCompleteOption, | ||||
| AutoCompleteOptionType, | AutoCompleteOptionType, | ||||
| getValue, | |||||
| } from "components/hook-form/RHFAutoComplete"; | } from "components/hook-form/RHFAutoComplete"; | ||||
| import useAPICall from "hooks/useAPICall"; | import useAPICall from "hooks/useAPICall"; | ||||
| import { useEffect, useState } from "react"; | import { useEffect, useState } from "react"; | ||||
| @@ -39,9 +39,9 @@ const PATHS = { | |||||
| // APP | // APP | ||||
| [makePathKey(PageID.APP_RECEIPT_ISSUING_ORDER_INDEX)]: | [makePathKey(PageID.APP_RECEIPT_ISSUING_ORDER_INDEX)]: | ||||
| "/app/receipt-issuing-oreder/:token", | |||||
| "/app/receipt-issuing-order/:token", | |||||
| [makePathKey(PageID.APP_RECEIPT_ISSUING_ORDER_MAIL_ORDER)]: | [makePathKey(PageID.APP_RECEIPT_ISSUING_ORDER_MAIL_ORDER)]: | ||||
| "/app/receipt-issuing-oreder/mail", | |||||
| "/app/receipt-issuing-order/mail", | |||||
| // 契約関連 | // 契約関連 | ||||
| [makePathKey(PageID.DASHBOARD_CONTRACT_LIST)]: | [makePathKey(PageID.DASHBOARD_CONTRACT_LIST)]: | ||||
| @@ -155,6 +155,9 @@ theme = { | |||||
| "&.Mui-disabled:before": { | "&.Mui-disabled:before": { | ||||
| borderBottomStyle: "none", | borderBottomStyle: "none", | ||||
| }, | }, | ||||
| "&.Mui-disabled": { | |||||
| WebkitTextFillColor: "black !important", | |||||
| }, | |||||
| }, | }, | ||||
| }, | }, | ||||
| }, | }, | ||||
| @@ -2,6 +2,7 @@ import { format, isValid, parse, parseISO } from "date-fns"; | |||||
| export const DEFAULT_DATE_FORMAT = "yyyy/MM/dd"; | export const DEFAULT_DATE_FORMAT = "yyyy/MM/dd"; | ||||
| export const DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; | export const DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; | ||||
| export const DEFAULT_DATE_TIME_FORMAT_ANOTHER1 = "yyyy-MM-dd HH:mm:ss"; | |||||
| export const DEFAULT_YYYYMM_FORMAT = "yyyyMM"; | export const DEFAULT_YYYYMM_FORMAT = "yyyyMM"; | ||||
| type Input = Date | string | null | undefined; | type Input = Date | string | null | undefined; | ||||
| @@ -35,7 +36,10 @@ export const dateParse = (source: Input): Date | null => { | |||||
| }; | }; | ||||
| export const dateTimeParse = (source: Input): Date | null => { | export const dateTimeParse = (source: Input): Date | null => { | ||||
| return parseFromFormat(source, DEFAULT_DATE_TIME_FORMAT); | |||||
| return ( | |||||
| parseFromFormat(source, DEFAULT_DATE_TIME_FORMAT) ?? | |||||
| parseFromFormat(source, DEFAULT_DATE_TIME_FORMAT_ANOTHER1) | |||||
| ); | |||||
| }; | }; | ||||
| const parseFromFormat = (source: Input, format: string): Date | null => { | const parseFromFormat = (source: Input, format: string): Date | null => { | ||||