@using economy.Models.Business.Number

@{
    ViewData["Title"] = "사업자등록번호 조회";
}

<div id="businessNumber" class="container">
    <h3>@ViewData["Title"]</h3>
    <br/>
    <form id="fSearch" method="post" accept-charset="UTF-8" rel="search" autocomplete="off" asp-controller="Business" asp-action="Search">
        <div class="row justify-content-center">
            <div class="col col-md-4">
                <div class="input-group">
                    <input type="text" name="query" class="form-control" value="@ViewBag?.Query" placeholder="예) 123-456-789101" aria-label="예) 123-456-789101" aria-describedby="123-456-789101" autofocus maxlength="255" />
                    <button class="btn btn-outline-danger" type="submit"><i class="bi bi-search"></i></button>
                </div>
            </div>
        </div>

        @if (@ViewBag?.Query is not null && @ViewBag.isError)
        {
            <div class="no-data">
                조회 결과가 없습니다.
            </div>
        }
        else
        {
            var result = (economy.Models.Business.Number.Response)ViewBag.result;

            @if (result?.Data != null && result.Data.Count > 0)
            {
                <div class="result w-75 m-auto mt-3 bg-transparent">
                    <table class="table table-bordered">
                        <colgroup>
                            <col width="30%" />
                            <col width="*" />
                        </colgroup>
                        <tbody>
                            @if (result?.Data != null && result.Data.Any())
                            {
                                @foreach(var row in result.Data)
                                {
                                    <tr>
                                        <th>사업자등록번호</th>
                                        <td>@row.BNo</td>
                                    </tr>
                                    <tr>
                                        <th>납세자상태</th>
                                        <td>
                                            @if (row.BStt != "")
                                            {
                                                <text>(@row.BSttCd) @row.BStt</text>
                                            }
                                            else
                                            {
                                                <text>-</text>
                                            }
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>과세유형메세지</th>
                                        <td>
                                            @if (row.TaxTypeCd != "")
                                            {
                                                <text>(@row.TaxTypeCd)</text>
                                            }
                                            @row.TaxType
                                        </td>
                                    </tr>
                                    @if (row.EndDt != "")
                                    {
                                        <tr>
                                            <th>폐업일</th>
                                            <td>@(row?.EndDt ?? "-")</td>
                                        </tr>
                                    }
                                    @if (row.UtccYn != "")
                                    {
                                        <tr>
                                            <th>단위과세전환폐업여부</th>
                                            <td>@(row?.UtccYn ?? "-")</td>
                                        </tr>
                                    }
                                    @if (row.TaxTypeChangeDt != "")
                                    {
                                        <tr>
                                            <th>최근과세유형전환일자</th>
                                            <td>@(row?.TaxTypeChangeDt ?? "-")</td>
                                        </tr>
                                    }
                                    @if (row.StaxInvoicePrintYnDt != "")
                                    {
                                        <tr>
                                            <th>세금계산서적용일자</th>
                                            <td>@(row?.StaxInvoicePrintYnDt ?? "-")</td>
                                        </tr>
                                    }
                                    @if (row.RbfTaxType != "")
                                    {
                                    <tr>
                                        <th>직전과세유형메세지</th>
                                        <td>
                                            @if (row.RbfTaxType != "")
                                            {
                                                <text>(@row.RbfTaxTypeCd) @row.RbfTaxType</text>
                                            }
                                        </td>
                                    </tr>
                                    }
                                }
                            }
                        </tbody>
                    </table>

                    <blockquote>
                        01：부가가치세 일반과세자<br/>
                        02：부가가치세 간이과세자<br />
                        07：부가가치세 간이과세자(세금계산서 발급사업자)<br />
                        99：해당없음
                    </blockquote>
                </div>
            }
            else
            {
                <div class="row mt-2">
                    <div class="col text-center">
                        <small>국세청에서 제공하는 사업자등록정보 진위확인 및 사업자등록 상태조회 API 서비스입니다.</small>
                    </div>
                </div>
                <br />
            }
        }
    </form>
</div>

@section Scripts {
    <script src="~/js/business.js" asp-append-version="true"></script>
}
@section Styles {
    <link href="~/css/style.css" rel="stylesheet" asp-append-version="true" />
}