세금계산서 엑셀다운로드 추가
This commit is contained in:
@@ -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,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -213,4 +213,14 @@ export interface TransactionInfoWrapProps {
|
|||||||
transactionInfo?: TransactionInfo;
|
transactionInfo?: TransactionInfo;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClickToShowInfo: (infoWrapKey: InfoWrapKeys) => void;
|
onClickToShowInfo: (infoWrapKey: InfoWrapKeys) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface SettlementsHistoryExcelParams {
|
||||||
|
email: string;
|
||||||
|
mid: string;
|
||||||
|
periodType: SettlementPeriodType
|
||||||
|
startDate: string;
|
||||||
|
endDate: string;
|
||||||
|
paymentMethod: SettlementPaymentMethod;
|
||||||
|
};
|
||||||
|
export interface SettlementsHistoryExcelResponse {};
|
||||||
@@ -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,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -165,4 +165,13 @@ export interface TransactionDetails {
|
|||||||
supplyAmount: number;
|
supplyAmount: number;
|
||||||
taxAmount: number;
|
taxAmount: number;
|
||||||
remarks: string;
|
remarks: string;
|
||||||
};
|
};
|
||||||
|
export interface VatReturnDownloadExcelParams {
|
||||||
|
email: string;
|
||||||
|
mid: string;
|
||||||
|
startMonth: string;
|
||||||
|
endMonth: string;
|
||||||
|
receiptType: VatReturnReceiptType;
|
||||||
|
targetType: VatReturnTargetType;
|
||||||
|
};
|
||||||
|
export interface VatReturnDownloadExcelResponse {};
|
||||||
@@ -8,6 +8,8 @@ import { DefaultRequestPagination, SortTypeKeys } from '@/entities/common/model/
|
|||||||
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
||||||
import {
|
import {
|
||||||
DetailData,
|
DetailData,
|
||||||
|
VatReturnDownloadExcelParams,
|
||||||
|
VatReturnDownloadExcelResponse,
|
||||||
VatReturnListContent,
|
VatReturnListContent,
|
||||||
VatReturnListParams,
|
VatReturnListParams,
|
||||||
VatReturnListResponse,
|
VatReturnListResponse,
|
||||||
@@ -22,7 +24,8 @@ import useIntersectionObserver from '@/widgets/intersection-observer';
|
|||||||
import { TaxInvoiceDetail } from './detail/tax-invoice-detail';
|
import { TaxInvoiceDetail } from './detail/tax-invoice-detail';
|
||||||
import { showAlert } from '@/widgets/show-alert';
|
import { showAlert } from '@/widgets/show-alert';
|
||||||
import { checkGrant } from '@/shared/lib/check-grant';
|
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 */
|
/* 세금계산서 48 */
|
||||||
const menuId = 48;
|
const menuId = 48;
|
||||||
@@ -42,11 +45,12 @@ export const ListWrap = () => {
|
|||||||
const [targetType, setTargetType] = useState<VatReturnTargetType>(VatReturnTargetType.ALL);
|
const [targetType, setTargetType] = useState<VatReturnTargetType>(VatReturnTargetType.ALL);
|
||||||
|
|
||||||
const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState<boolean>(false);
|
const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState<boolean>(false);
|
||||||
const [taxInvoiceSampleOn, setTaxInvoiceSampleOn] = useState<boolean>(false);
|
|
||||||
|
|
||||||
const [detailOn, setDetailOn] = useState<boolean>(false);
|
const [detailOn, setDetailOn] = useState<boolean>(false);
|
||||||
const [detailTaxInvoiceNumber, setDetailTaxInvoiceNumber] = useState<string>('');
|
const [detailTaxInvoiceNumber, setDetailTaxInvoiceNumber] = useState<string>('');
|
||||||
|
|
||||||
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
||||||
|
const { mutateAsync: vatReturnDownloadExcel } = useVatReturnDownloadExcelMutation();
|
||||||
|
|
||||||
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||||
entries.forEach((entry: IntersectionObserverEntry) => {
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||||
@@ -132,8 +136,26 @@ export const ListWrap = () => {
|
|||||||
selectedMode: DownloadSelectedMode,
|
selectedMode: DownloadSelectedMode,
|
||||||
userEmail?: string
|
userEmail?: string
|
||||||
) => {
|
) => {
|
||||||
if(selectedMode === DownloadSelectedMode.IMAGE){
|
if(selectedMode === DownloadSelectedMode.EMAIL
|
||||||
setTaxInvoiceSampleOn(true);
|
&& !!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 }
|
sendRequest={ onRequestDownloadExcel }
|
||||||
></DownloadBottomSheet>
|
></DownloadBottomSheet>
|
||||||
}
|
}
|
||||||
{ !!taxInvoiceSampleOn &&
|
|
||||||
<TaxInvoiceSample
|
|
||||||
taxInvoiceSampleOn={ taxInvoiceSampleOn }
|
|
||||||
setTaxInvoiceSampleOn={ setTaxInvoiceSampleOn }
|
|
||||||
></TaxInvoiceSample>
|
|
||||||
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -33,5 +33,9 @@ export const API_URL_SETTLEMENT = {
|
|||||||
// POST: 정산내역 거래건별 조회
|
// POST: 정산내역 거래건별 조회
|
||||||
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/settlements/calendar`;
|
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`;
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -23,5 +23,9 @@ export const API_URL_VAT_RETURN = {
|
|||||||
vatReturnBreakdown: () => {
|
vatReturnBreakdown: () => {
|
||||||
// POST: 세금계산서 세부내역 조회
|
// POST: 세금계산서 세부내역 조회
|
||||||
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/vat-return/breakdown`;
|
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`;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user