세금계산서 엑셀다운로드 추가

This commit is contained in:
focp212@naver.com
2025-11-11 10:38:23 +09:00
parent f72fcf0604
commit 6bd57708cf
7 changed files with 135 additions and 15 deletions

View File

@@ -0,0 +1,39 @@
import axios from 'axios';
import { API_URL_SETTLEMENT } from '@/shared/api/api-url-settlement';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
SettlementsHistoryExcelParams,
SettlementsHistoryExcelResponse
} from '../model/types';
import {
useMutation,
UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';
export const settlementsHistoryExcel = (params: SettlementsHistoryExcelParams) => {
let headerOptions = {
menuId: 37,
apiType: 'DOWNLOAD'
};
let options = {
headers: {
'X-User-Agent': getHeaderUserAgent(headerOptions)
}
};
return resultify(
axios.post<SettlementsHistoryExcelResponse>(API_URL_SETTLEMENT.settlementsHistoryExcel(), params, options),
);
};
export const useSettlementsHistoryExcelMutation = (options?: UseMutationOptions<SettlementsHistoryExcelResponse, NiceAxiosError, SettlementsHistoryExcelParams>) => {
const mutation = useMutation<SettlementsHistoryExcelResponse, NiceAxiosError, SettlementsHistoryExcelParams>({
...options,
mutationFn: (params: SettlementsHistoryExcelParams) => settlementsHistoryExcel(params),
});
return {
...mutation,
};
};

View File

@@ -214,3 +214,13 @@ export interface TransactionInfoWrapProps {
isOpen: boolean;
onClickToShowInfo: (infoWrapKey: InfoWrapKeys) => void;
};
export interface SettlementsHistoryExcelParams {
email: string;
mid: string;
periodType: SettlementPeriodType
startDate: string;
endDate: string;
paymentMethod: SettlementPaymentMethod;
};
export interface SettlementsHistoryExcelResponse {};

View File

@@ -0,0 +1,39 @@
import axios from 'axios';
import { API_URL_VAT_RETURN } from '@/shared/api/api-url-vat-return';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
VatReturnDownloadExcelParams,
VatReturnDownloadExcelResponse
} from '../model/types';
import {
useMutation,
UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';
export const vatReturnDownloadExcel = (params: VatReturnDownloadExcelParams) => {
let headerOptions = {
menuId: 48,
apiType: 'SELECT'
};
let options = {
headers: {
'X-User-Agent': getHeaderUserAgent(headerOptions)
}
};
return resultify(
axios.post<VatReturnDownloadExcelResponse>(API_URL_VAT_RETURN.vatReturnDownloadExcel(), params, options),
);
};
export const useVatReturnDownloadExcelMutation = (options?: UseMutationOptions<VatReturnDownloadExcelResponse, NiceAxiosError, VatReturnDownloadExcelParams>) => {
const mutation = useMutation<VatReturnDownloadExcelResponse, NiceAxiosError, VatReturnDownloadExcelParams>({
...options,
mutationFn: (params: VatReturnDownloadExcelParams) => vatReturnDownloadExcel(params),
});
return {
...mutation,
};
};

View File

@@ -166,3 +166,12 @@ export interface TransactionDetails {
taxAmount: number;
remarks: string;
};
export interface VatReturnDownloadExcelParams {
email: string;
mid: string;
startMonth: string;
endMonth: string;
receiptType: VatReturnReceiptType;
targetType: VatReturnTargetType;
};
export interface VatReturnDownloadExcelResponse {};

View File

@@ -8,6 +8,8 @@ import { DefaultRequestPagination, SortTypeKeys } from '@/entities/common/model/
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
import {
DetailData,
VatReturnDownloadExcelParams,
VatReturnDownloadExcelResponse,
VatReturnListContent,
VatReturnListParams,
VatReturnListResponse,
@@ -22,7 +24,8 @@ import useIntersectionObserver from '@/widgets/intersection-observer';
import { TaxInvoiceDetail } from './detail/tax-invoice-detail';
import { showAlert } from '@/widgets/show-alert';
import { checkGrant } from '@/shared/lib/check-grant';
import { TaxInvoiceSample } from '@/entities/common/ui/tax-invoice-sample';
import { useVatReturnDownloadExcelMutation } from '../api/use-vat-return-download-excel-mutation';
import { snackBar } from '@/shared/lib';
/* 세금계산서 48 */
const menuId = 48;
@@ -42,11 +45,12 @@ export const ListWrap = () => {
const [targetType, setTargetType] = useState<VatReturnTargetType>(VatReturnTargetType.ALL);
const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState<boolean>(false);
const [taxInvoiceSampleOn, setTaxInvoiceSampleOn] = useState<boolean>(false);
const [detailOn, setDetailOn] = useState<boolean>(false);
const [detailTaxInvoiceNumber, setDetailTaxInvoiceNumber] = useState<string>('');
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
const { mutateAsync: vatReturnDownloadExcel } = useVatReturnDownloadExcelMutation();
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
entries.forEach((entry: IntersectionObserverEntry) => {
@@ -132,8 +136,26 @@ export const ListWrap = () => {
selectedMode: DownloadSelectedMode,
userEmail?: string
) => {
if(selectedMode === DownloadSelectedMode.IMAGE){
setTaxInvoiceSampleOn(true);
if(selectedMode === DownloadSelectedMode.EMAIL
&& !!userEmail
){
let params: VatReturnDownloadExcelParams = {
email: userEmail,
mid: mid,
startMonth: startMonth,
endMonth: endMonth,
receiptType: receiptType,
targetType: targetType
};
vatReturnDownloadExcel(params).then((rs: VatReturnDownloadExcelResponse) => {
console.log(rs);
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
}).catch((e: any) => {
if(e.response?.data?.error?.message){
snackBar(e.response?.data?.error?.message);
return;
}
});
}
};
@@ -262,13 +284,6 @@ export const ListWrap = () => {
sendRequest={ onRequestDownloadExcel }
></DownloadBottomSheet>
}
{ !!taxInvoiceSampleOn &&
<TaxInvoiceSample
taxInvoiceSampleOn={ taxInvoiceSampleOn }
setTaxInvoiceSampleOn={ setTaxInvoiceSampleOn }
></TaxInvoiceSample>
}
</>
);
};

View File

@@ -33,5 +33,9 @@ export const API_URL_SETTLEMENT = {
// POST: 정산내역 거래건별 조회
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/settlements/calendar`;
},
settlementsHistoryExcel: () => {
// POST: 정산내역 엑셀 다운로드
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/settlements/history/excel`;
},
};

View File

@@ -23,5 +23,9 @@ export const API_URL_VAT_RETURN = {
vatReturnBreakdown: () => {
// POST: 세금계산서 세부내역 조회
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/vat-return/breakdown`;
}
},
vatReturnDownloadExcel: () => {
// POST: 세금계산서 엑셀 다운로드
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/vat-return/download/excel`;
},
};