mid 관련 수정
This commit is contained in:
@@ -30,7 +30,7 @@ export interface VatReturnListParams {
|
||||
endDate?: string;
|
||||
receiptType?: VatReturnReceiptType;
|
||||
targetType?: VatReturnTargetType;
|
||||
pagination?: DefaultRequestPagination;
|
||||
page?: DefaultRequestPagination;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ import { useEffect, useState } from 'react';
|
||||
import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||
import { ListFilter } from './filter/list-filter';
|
||||
import { SortTypeBox } from '@/entities/common/ui/sort-type-box';
|
||||
import { SortTypeKeys } from '@/entities/common/model/types';
|
||||
import { DefaultRequestPagination, SortTypeKeys } from '@/entities/common/model/types';
|
||||
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
||||
import {
|
||||
VatReturnListContent,
|
||||
VatReturnListParams,
|
||||
VatReturnListResponse,
|
||||
VatReturnReceiptType,
|
||||
VatReturnTargetType
|
||||
} from '../model/types';
|
||||
@@ -21,33 +22,33 @@ export const ListWrap = () => {
|
||||
|
||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||
const [listItems, setListItems] = useState<Record<string, Array<VatReturnListContent>>>({});
|
||||
const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM);
|
||||
const [listItems, setListItems] = useState<Array<VatReturnListContent>>([]);
|
||||
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
|
||||
const [mid, setMid] = useState<string>(userMid);
|
||||
const [startDate, setStartDate] = useState(moment().subtract(1, 'month').format('YYYY.MM'));
|
||||
const [endDate, setEndDate] = useState(moment().format('YYYY.MM'));
|
||||
const [startDate, setStartDate] = useState(moment().subtract(1, 'month').format('YYYYMM'));
|
||||
const [endDate, setEndDate] = useState(moment().format('YYYYMM'));
|
||||
const [receiptType, setReceiptType] = useState<VatReturnReceiptType>(VatReturnReceiptType.ALL);
|
||||
const [targetType, setTargetType] = useState<VatReturnTargetType>(VatReturnTargetType.ALL);
|
||||
|
||||
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
||||
|
||||
const callList = () => {
|
||||
let strStartDate = moment(startDate).format('YYYYMM');
|
||||
let newStartDate = moment(strStartDate+'01').format('YYYY-MM-DD');
|
||||
|
||||
let strEndtDate = moment(endDate).format('YYYYMM');
|
||||
let lastDate = moment(endDate).endOf('month').date();
|
||||
let newEndDate = moment(strEndtDate+lastDate).format('YYYY-MM-DD');
|
||||
|
||||
const callList = (option?: {
|
||||
sortType?: SortTypeKeys
|
||||
}) => {
|
||||
let params: VatReturnListParams = {
|
||||
mid: mid,
|
||||
startDate: newStartDate,
|
||||
endDate: newEndDate,
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
receiptType: receiptType,
|
||||
targetType: targetType,
|
||||
page: pageParam
|
||||
};
|
||||
vatReturnList(params).then((rs) => {
|
||||
setListItems(assembleData(rs.content));
|
||||
if(params.page){
|
||||
params.page.sortType = option?.sortType || sortType;
|
||||
setPageParam(params.page);
|
||||
}
|
||||
vatReturnList(params).then((rs: VatReturnListResponse) => {
|
||||
setListItems(rs.content);
|
||||
});
|
||||
|
||||
};
|
||||
@@ -65,35 +66,47 @@ export const ListWrap = () => {
|
||||
|
||||
const getListDateGroup = () => {
|
||||
let rs = [];
|
||||
if(Object.keys(listItems).length > 0){
|
||||
for (const [key, value] of Object.entries(listItems)) {
|
||||
rs.push(
|
||||
<ListDateGroup
|
||||
key={ key }
|
||||
date={ key }
|
||||
items={ value }
|
||||
></ListDateGroup>
|
||||
);
|
||||
let date = '';
|
||||
let list: Array<VatReturnListContent> = [];
|
||||
|
||||
for(let i=0;i<listItems.length;i++){
|
||||
let item = listItems[i];
|
||||
if(!!item){
|
||||
let issueDateTime = item?.issueDate;
|
||||
let issueDate = issueDateTime?.substr(0, 8);
|
||||
if(!!issueDate){
|
||||
if(i === 0){
|
||||
date = issueDate;
|
||||
}
|
||||
if(date !== issueDate){
|
||||
date = issueDate;
|
||||
if(list.length > 0){
|
||||
rs.push(
|
||||
<ListDateGroup
|
||||
key={ date + '-' + i }
|
||||
date={ date }
|
||||
items={ list }
|
||||
></ListDateGroup>
|
||||
);
|
||||
}
|
||||
list = [];
|
||||
}
|
||||
list.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(list.length > 0){
|
||||
rs.push(
|
||||
<ListDateGroup
|
||||
key={ date + '-last' }
|
||||
date={ date }
|
||||
items={ list }
|
||||
></ListDateGroup>
|
||||
);
|
||||
}
|
||||
return rs;
|
||||
};
|
||||
|
||||
const assembleData = (content: Array<VatReturnListContent>) => {
|
||||
let data: any = {};
|
||||
if(content && content.length > 0){
|
||||
for(let i=0;i<content?.length;i++){
|
||||
let groupDate = moment(content[i]?.issueDate).format('YYYYMMDD');
|
||||
if(!!groupDate && !data.hasOwnProperty(groupDate)){
|
||||
data[groupDate] = [];
|
||||
}
|
||||
if(!!groupDate && data.hasOwnProperty(groupDate)){
|
||||
data[groupDate].push(content[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="summary-section pt-30">
|
||||
@@ -102,7 +115,7 @@ export const ListWrap = () => {
|
||||
<input
|
||||
type="text"
|
||||
className="credit-period"
|
||||
value={moment(startDate).format('YYYY.MM.DD') + '-' + moment(endDate).format('YYYY.MM.DD')}
|
||||
value={ moment(startDate+'01').format('YYYY.MM') + '-' + moment(endDate+'01').format('YYYY.MM')}
|
||||
readOnly={ true }
|
||||
/>
|
||||
<button
|
||||
|
||||
@@ -12,14 +12,15 @@ import { useVatReturnReferenceRequestMutation } from '../api/use-vat-return-refe
|
||||
|
||||
export const ReferenceWrap = () => {
|
||||
const midOptions = useStore.getState().UserStore.selectOptionsMids;
|
||||
|
||||
const userMid = useStore.getState().UserStore.mid;
|
||||
|
||||
const [success, setSuccess] = useState<boolean>(false);
|
||||
|
||||
const [successPageOn, setSuccessPageOn] = useState<boolean>(false);
|
||||
const [failPageOn, setFailPageOn] = useState<boolean>(false);
|
||||
const [mid, setMid] = useState<string>('');
|
||||
const [startDate, setStartDate] = useState<string>(moment().format('YYYY.MM.DD'));
|
||||
const [endDate, setEndDate] = useState<string>(moment().format('YYYY.MM.DD'));
|
||||
const [mid, setMid] = useState<string>(userMid);
|
||||
const [startDate, setStartDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||
const [endDate, setEndDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||
const [payTax, setPayTax] = useState<VatReturnPayTax>(VatReturnPayTax.Tax);
|
||||
const [email, setEmail] = useState<string>('');
|
||||
const [errorMsg, setErrorMsg] = useState<string>('');
|
||||
@@ -80,7 +81,7 @@ export const ReferenceWrap = () => {
|
||||
selectOptions={ EmailOptions }
|
||||
></FilterSelect>
|
||||
</div>
|
||||
<div className="apply-row bottom-padding">
|
||||
<div className="apply-row">
|
||||
<button
|
||||
className="btn-50 btn-blue flex-1"
|
||||
onClick={ onClickToResquest }
|
||||
|
||||
Reference in New Issue
Block a user