Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 세금계산서 역발행 요청 기능 구현 #194

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.baroservice.ws.ArrayOfTaxInvoiceTradeLineItem;
import com.baroservice.ws.InvoiceParty;
import com.baroservice.ws.TaxInvoice;
import com.baroservice.ws.TaxInvoiceStateEX;
import com.baroservice.ws.TaxInvoiceTradeLineItem;
import com.jangburich.domain.barobill.dto.request.GetCertificateRegistURLRequest;
import com.jangburich.domain.barobill.dto.request.RegistAndReverseIssueTaxInvoiceRequest;
Expand Down Expand Up @@ -48,16 +49,53 @@ public void getCertificateRegistURL(GetCertificateRegistURLRequest getCertificat
}
}

@Transactional
public void procTaxInvoice() {
String certKey = CERT_KEY;
String corpNum = "7542401719";
String mgtKey = "000001-E";
String procType = "CANCEL";
String memo = "test";

int result = barobillApiService.taxInvoice.procTaxInvoice(certKey, corpNum, mgtKey, procType, memo);

if (result < 0) { // 호출 실패
System.out.println(result);
} else { // 호출 성공
System.out.println(result);
}
}

public void getTaxInvoiceStateEX() {
String certKey = CERT_KEY;
String corpNum = "7493500897";
String mgtKey = "000001-R";

TaxInvoiceStateEX result = barobillApiService.taxInvoice.getTaxInvoiceStateEX(certKey, corpNum, mgtKey);

if (result.getBarobillState() < 0) { // 호출 실패
System.out.println(result.getBarobillState());
} else { // 호출 성공
// 필드정보는 레퍼런스를 참고해주세요.
System.out.println(result.getBarobillState());
}
}

@Transactional
public void registAndReverseIssueTaxInvoice(
RegistAndReverseIssueTaxInvoiceRequest registAndReverseIssueTaxInvoiceRequest) {
// 공급자, 공급받는자의 관리번호 채번
String invoicerMgtNum = "000001-R";
String invoiceeMgtNum = "000001-E";
// String invoicerMgtNum = "000003-R";
// String invoiceeMgtNum = "000003-E";

String invoicerMgtNum = registAndReverseIssueTaxInvoiceRequest.invoicerMgtNum();
String invoiceeMgtNum = registAndReverseIssueTaxInvoiceRequest.invoiceeMgtNum();

// 공급자, 공급받는자의 바로빌 아이디 불러오기
String invoicerBarobillID = registAndReverseIssueTaxInvoiceRequest.invoicerBarobillID();
String invoiceeBarobillID = registAndReverseIssueTaxInvoiceRequest.invoiceeBarobillID();
// String invoicerBarobillID = registAndReverseIssueTaxInvoiceRequest.invoicerBarobillID();
// String invoiceeBarobillID = registAndReverseIssueTaxInvoiceRequest.invoiceeBarobillID();
String invoicerBarobillID = "parisbutchershop";
String invoiceeBarobillID = "tkddn0518";

// 세금계산서 내용을 담은 클래스(또는 구조체) 생성
TaxInvoice taxInvoice = new TaxInvoice();
Expand All @@ -72,7 +110,7 @@ public void registAndReverseIssueTaxInvoice(
taxInvoice.setTaxCalcType(1);
taxInvoice.setPurposeType(1);

taxInvoice.setWriteDate("20241129");
taxInvoice.setWriteDate("20241202");

taxInvoice.setAmountTotal("100");
taxInvoice.setTaxTotal("100");
Expand All @@ -97,34 +135,34 @@ public void registAndReverseIssueTaxInvoice(
// 공급자 정보
taxInvoice.setInvoicerParty(new InvoiceParty());
taxInvoice.getInvoicerParty().setMgtNum(invoicerMgtNum);
taxInvoice.getInvoicerParty().setCorpNum("");
taxInvoice.getInvoicerParty().setCorpNum("7493500897");
taxInvoice.getInvoicerParty().setTaxRegID("");
taxInvoice.getInvoicerParty().setCorpName("partisbutchershop");
taxInvoice.getInvoicerParty().setCEOName("");
taxInvoice.getInvoicerParty().setAddr("");
taxInvoice.getInvoicerParty().setCorpName("parisbutchershop");
taxInvoice.getInvoicerParty().setCEOName("윤원자");
taxInvoice.getInvoicerParty().setAddr("대구광역시 달서구 달구벌대로344길 23");
taxInvoice.getInvoicerParty().setBizType("한식");
taxInvoice.getInvoicerParty().setBizClass("음식점업");
taxInvoice.getInvoicerParty().setContactID(invoicerBarobillID);
taxInvoice.getInvoicerParty().setContactName("");
taxInvoice.getInvoicerParty().setContactName("빠리정육점");
taxInvoice.getInvoicerParty().setTEL("");
taxInvoice.getInvoicerParty().setHP("");
taxInvoice.getInvoicerParty().setEmail("");
taxInvoice.getInvoicerParty().setEmail("[email protected]");

//공급받는자 정보
taxInvoice.setInvoiceeParty(new InvoiceParty());
taxInvoice.getInvoiceeParty().setMgtNum(invoiceeMgtNum);
taxInvoice.getInvoiceeParty().setCorpNum("");
taxInvoice.getInvoiceeParty().setCorpNum("7542401719");
taxInvoice.getInvoiceeParty().setTaxRegID("");
taxInvoice.getInvoiceeParty().setCorpName("Jangburich");
taxInvoice.getInvoiceeParty().setCEOName("");
taxInvoice.getInvoiceeParty().setAddr("");
taxInvoice.getInvoiceeParty().setBizType("");
taxInvoice.getInvoiceeParty().setBizClass("");
taxInvoice.getInvoiceeParty().setCEOName("변상우");
taxInvoice.getInvoiceeParty().setAddr("충북 청주시 상당구 중앙로 80 (북문로3가, 청주행정타운 코아루휴티스)");
taxInvoice.getInvoiceeParty().setBizType("응용 소프트웨어 개발 및 공급업");
taxInvoice.getInvoiceeParty().setBizClass("정보통신업");
taxInvoice.getInvoiceeParty().setContactID(invoiceeBarobillID);
taxInvoice.getInvoiceeParty().setContactName("");
taxInvoice.getInvoiceeParty().setContactName("하이볼리");
taxInvoice.getInvoiceeParty().setTEL("");
taxInvoice.getInvoiceeParty().setHP("");
taxInvoice.getInvoiceeParty().setEmail("");
taxInvoice.getInvoiceeParty().setEmail("[email protected]");

// 수탁자 정보
taxInvoice.setBrokerParty(new InvoiceParty());
Expand Down Expand Up @@ -156,7 +194,7 @@ public void registAndReverseIssueTaxInvoice(

taxInvoice.getTaxInvoiceTradeLineItems().getTaxInvoiceTradeLineItem().add(taxInvoiceTradeLineItem);

int result = barobillApiService.taxInvoice.registAndReverseIssueTaxInvoice(CERT_KEY, "", taxInvoice,
int result = barobillApiService.taxInvoice.registAndReverseIssueTaxInvoice(CERT_KEY, taxInvoice.getInvoiceeParty().getCorpNum(), taxInvoice,
false,
false, "");

Expand All @@ -169,4 +207,18 @@ public void registAndReverseIssueTaxInvoice(
System.out.println("성공");
}
}

public void deleteTaxInvoice() {
String certKey = CERT_KEY;
String corpNum = "7493500897";
String mgtKey = "000001-R";

int result = barobillApiService.taxInvoice.deleteTaxInvoice(certKey, corpNum, mgtKey);

if (result < 0) { // 호출 실패
System.out.println(result);
} else { // 호출 성공
System.out.println(result);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.jangburich.domain.barobill.dto.request;

public record RegistAndReverseIssueTaxInvoiceRequest(
String invoicerBarobillID,
String invoiceeBarobillID
String invoicerMgtNum,
String invoiceeMgtNum
) {

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.jangburich.domain.barobill.presentation;

import com.jangburich.domain.barobill.application.BarobillService;
import com.jangburich.domain.barobill.dto.request.GetCertificateRegistURLRequest;
import com.jangburich.domain.barobill.dto.request.RegistAndReverseIssueTaxInvoiceRequest;
import com.jangburich.domain.barobill.dto.request.RegistCorpRequest;
import com.jangburich.global.payload.Message;
import com.jangburich.global.payload.ResponseCustom;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -21,6 +22,7 @@ public class BarobillController {

private final BarobillService barobillService;

@Operation(summary = "바로빌 가입 및 회원사 등록", description = "소상공인의 사업자로 바로빌 회원가입 + 장부리치의 회원사로 등록합니다.")
@PostMapping
public ResponseCustom<Message> registCorp(
@RequestBody RegistCorpRequest registCorpRequest
Expand All @@ -29,19 +31,31 @@ public ResponseCustom<Message> registCorp(
return ResponseCustom.OK(Message.builder().message("success").build());
}

@PostMapping("/registCertificate")
public ResponseCustom<Message> getCertificateRegistURL(
@RequestBody GetCertificateRegistURLRequest getCertificateRegistURLRequest
) {
barobillService.getCertificateRegistURL(getCertificateRegistURLRequest);
@Operation(summary = "세금계산서 역발행 요청", description = "세금 계산서를 소상공인이 역발행 요청합니다.")
@PostMapping("/registAndReverseIssueTaxInvoice")
public ResponseCustom<Message> registAndReverseIssueTaxInvoice(@RequestBody RegistAndReverseIssueTaxInvoiceRequest registAndReverseIssueTaxInvoiceRequest) {
barobillService.registAndReverseIssueTaxInvoice(registAndReverseIssueTaxInvoiceRequest);
return ResponseCustom.OK(Message.builder().message("success").build());
}

@PostMapping("/registAndReverseIssueTaxInvoice")
public ResponseCustom<Message> registAndReverseIssueTaxInvoice(
@RequestBody RegistAndReverseIssueTaxInvoiceRequest registAndReverseIssueTaxInvoiceRequest
) {
barobillService.registAndReverseIssueTaxInvoice(registAndReverseIssueTaxInvoiceRequest);
@Operation(summary = "세금계산서 역발행 취소", description = "세금 계산서 역발행 취소(test)")
@PostMapping("/cancel")
public ResponseCustom<Message> cancel() {
barobillService.procTaxInvoice();
return ResponseCustom.OK(Message.builder().message("success").build());
}

@Operation(summary = "세금계산서 상태조회", description = "세금계산서 상태를 조회합니다.")
@GetMapping("/testget")
public ResponseCustom<Message> get() {
barobillService.getTaxInvoiceStateEX();
return ResponseCustom.OK(Message.builder().message("success").build());
}

@Operation(summary = "세금계산서 삭제", description = "세금계산서를 삭제합니다.")
@PostMapping("/delete")
public ResponseCustom<Message> delete() {
barobillService.deleteTaxInvoice();
return ResponseCustom.OK(Message.builder().message("success").build());
}
}
Loading