# 수집 내역 확인

## 1. Search - 수집 내역 확인

홈택스에서 수집된 현금영수증 매입/매출 내역을 확인합니다.

- 18개 항목으로 구성된 내역 확인이 가능합니다.

```pascal
function Search(CorpNum : String; JobID : String; TradeType : Array Of String; TradeUsage : Array Of String; Page : Integer; PerPage : Integer; Order : String; UserID : String) : THomeTaxCBSearchList;
```

> 매개변수 Page, PerPage, Order를 이용하여 페이징 기능을 구현할 수 있습니다.

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- JobID `type: String` `length: 18` `required: Y` `description: 팝빌에서 할당한 작업아이디`
  - [\[RequestJob - 수집 요청\]](https://developers.popbill.com/reference/htcashbill/delphi/api/job#RequestJob) API의 반환값
- TradeType `type: Array Of String` `length: -` `required: N` `description: 현금영수증 문서형태 (다중 선택 가능)`
  - `N`: 승인 현금영수증
  - `C`: 취소 현금영수증
  - 기본값 : 전체조회
- TradeUsage `type: Array Of String` `length: -` `required: N` `description: 현금영수증 거래구분 (다중 선택 가능)`
  - `P`: 소득공제용
  - `C`: 지출증빙용
  - 기본값 : 전체조회
- Page `type: Integer` `length: -` `required: N` `description: 목록 페이지번호`
  - 기본값 : 1
- PerPage `type: Integer` `length: -` `required: N` `description: 페이지당 표시할 목록 건수`
  - 최대 : 1,000건
  - 기본값 : 500건
- Order `type: String` `length: 1` `required: N` `description: 목록 정렬 방향`
  - `D`: 내림차순 : 기본값
  - `A`: 오름차순
  - API를 호출하고 반환 받은 거래일시(tradeDT) 기준
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`

### 응답

**THomeTaxCBSearchList**

- code `type: Integer` `length: -` `description: API 처리에 대한 응답코드`
  - `1`: 성공
- message `type: String` `length: -` `description: API 처리에 대한 응답메시지`
- total `type: Integer` `length: -` `description: 총 검색결과 건수`
- perPage `type: Integer` `length: -` `description: 페이지당 목록 건수`
- pageNum `type: Integer` `length: -` `description: 페이지 번호`
- pageCount `type: Integer` `length: -` `description: 페이지 개수`
- list `type: THometaxCashbill` `length: -` `description: 현금영수증 정보`
  - 최대 : 1,000건
  - ntsconfirmNum `type: String` `length: 24` `description: 국세청승인번호`
  - tradeDate `type: String` `length: 8` `description: 거래일자`
    - 형식 : yyyyMMdd
  - tradeDT `type: String` `length: 14` `description: 거래일시`
    - 형식 : yyyyMMddHHmmss
  - tradeType `type: String` `length: 4` `description: 문서형태`
    - `승인거래`
    - `취소거래`
  - tradeUsage `type: String` `length: 5` `description: 거래구분`
    - `소득공제용`
    - `지출증빙용`
  - totalAmount `type: String` `length: 9` `description: 거래금액`
  - supplyCost `type: String` `length: 9` `description: 공급가액`
  - tax `type: String` `length: 9` `description: 부가세`
  - serviceFee `type: String` `length: 9` `description: 봉사료`
  - invoiceType `type: String` `length: 2` `description: 현금영수증 유형`
    - `매입`
    - `매출`
  - franchiseCorpNum `type: String` `length: 10` `description: 가맹점(발행자) 사업자번호`
    - {invoiceType}="매입" 경우 반환
  - franchiseCorpName `type: String` `length: 200` `description: 가맹점(발행자) 상호`
    - {invoiceType}="매입" 경우 반환
  - franchiseCorpType `type: Integer` `length: 1` `description: 가맹점(발행자) 사업자유형`
    - `1`: 일반과세자
    - `2`: 간이과세자
    - `3`: 과세특례자
    - `4`: 면세사업자
    - `5`: 법인사업자
    - {invoiceType}="매입" 경우 반환
  - identityNum `type: String` `length: 4` `description: 식별번호`
    - 식별번호의 마지막 4자리 숫자만 반환
  - identityNumType `type: Integer` `length: 1` `description: 식별번호 유형`
    - `1`: 주민등록번호
    - `2`: 사업자번호
    - `3`: 휴대폰번호
    - `4`: 카드번호
  - customerName `type: String` `length: 70` `description: 구매자(고객) 성명`
  - cardOwnerName `type: String` `length: 70` `description: 카드소유자명`
  - deductionType `type: Integer` `length: 1` `description: 공제유형`
    - `1`: 공제
    - `2`: 공제
    - `3`: 불공제
    - `4`: 불공제

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`

## 2. Summary - 수집 내역 합계

홈택스에서 수집된 현금영수증 매입/매출 내역의 합계정보를 제공합니다.\
※ 합계정보 - 수집 건수, 공급가액 합계, 부가세 합계, 봉사료 합계, 거래금액 합계 (공급가액 합계+부가세 합계+봉사료 합계)

```pascal
function Summary(CorpNum : String; JobID : String; TradeType : Array Of String; TradeUsage : Array Of String; UserID : String) : TCashbillSummary;
```

### 요청

**Parameters**

- CorpNum `type: String` `length: 10` `required: Y` `description: 팝빌회원 사업자번호 ('-' 제외)`
- JobID `type: String` `length: 18` `required: Y` `description: 팝빌에서 할당한 작업아이디`
  - [\[RequestJob - 수집 요청\]](https://developers.popbill.com/reference/htcashbill/delphi/api/job#RequestJob) API의 반환값
- TradeType `type: Array Of String` `length: -` `required: N` `description: 현금영수증 문서형태 (다중 선택 가능)`
  - `N`: 승인 현금영수증
  - `C`: 취소 현금영수증
  - 기본값 : 전체조회
- TradeUsage `type: Array Of String` `length: -` `required: N` `description: 현금영수증 거래구분 (다중 선택 가능)`
  - `P`: 소득공제용
  - `C`: 지출증빙용
  - 기본값 : 전체조회
- UserID `type: String` `length: 50` `required: N` `description: 팝빌회원 아이디`

### 응답

**TCashbillSummary**

- count `type: Integer` `length: -` `description: 수집 건수`
- supplyCostTotal `type: Integer` `length: 18` `description: 공급가액 합계`
- taxTotal `type: Integer` `length: 18` `description: 부가세 합계`
- serviceFeeTotal `type: Integer` `length: 18` `description: 봉사료 합계`
- amountTotal `type: Integer` `length: 18` `description: 거래금액 합계 (공급가액 합계+부가세 합계+봉사료 합계)`

### 예외

**EPopbillException**

- code `type: LongInt` `length: -` `description: API 처리 실패에 대한 오류코드`
  - 음의 정수 8자리 숫자값 [\[참고\] 오류코드](https://developers.popbill.com/error-code)
- message `type: String` `length: -` `description: API 처리 실패에 대한 오류메시지`
