Files
KIN/approval/doc_expense_taxList.asp
2025-09-29 17:55:08 +09:00

733 lines
31 KiB
Plaintext

<!-- #include virtual = "include/header.asp" -->
<!-- #include virtual = "include/left.asp" -->
<%
Dim Query, i, j
Dim sMonth, NTSConfirmNum, Company
NTSConfirmNum = Request("NTSConfirmNum")
sMonth = Request("sMonth")
Company = Request("Company")
If sMonth = "" Then
If day(date) >= 5 Then
sMonth = Left(date, 7)
Else
sMonth = Left(DateAdd("M", -1, date), 7)
End If
End If
userEmail = ""
If Session("N_Depart") <> "M" Then
userEmail = Session("User_Mail")
End If
%>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<style>
.page-link{
color: #6d7b90;
border: 1px solid #6d7b90;
}
.page-item.active .page-link{
color: #fff;
background-color: #6d7b90;
border-color: #6d7b90;
}
.page-item.disabled .page-link{
color: #b7c0cd;
background-color: transparent;
border-color: #b7c0cd;
}
#resultTb > tbody > tr:hover > td{
background-color: #d7dfeb;
}
#resultTb > tbody > tr > td:nth-child(7),
#resultTb > tbody > tr > td:nth-child(8),
#resultTb > tbody > tr > td:nth-child(9),
#resultTb > tbody > tr > td:nth-child(10){
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#filterMail{
width: 300px;
display: inline-flex;
}
#paperItem .input-group-text{
width:100px;
}
#paperItem input, #paperItem select{
width:120px;
}
</style>
<!-- Main content -->
<div class="content-body p-2">
<div class="content pb-2">
<div class="container-fluid">
<div class="row row-0">
<div class="col-12">
<label for="searchType_num" class="m-2"><input type="radio" id="searchType_num" name="searchType" value="num" /> 국세청 승인번호</label>
<label for="searchType_month" class="m-2"><input type="radio" id="searchType_month" name="searchType" value="month" /> 월별</label>
<label for="searchType_paper" class="m-2"><input type="radio" id="searchType_paper" name="searchType" value="paper" /> 종이세금계산서</label>
<button class="btn btn-danger float-right d-none ml-2" type="button" id="deleteBtn">삭제</button>
<button class="btn btn-secondary float-right" type="button" id="selectBtn">선택</button>
</div>
</div>
<div class="row row-0 mt-1">
<div class="col-12">
<div class="input-group d-none searchItem" id="numItem">
<input type="text" class="form-control border" id="NTSConfirmNum" />
<div class="input-group-append">
<button class="btn btn-primary p-0" type="button" id="searchBtn"><i class="fas fa-search"></i></button>
</div>
</div>
<div class="input-group d-none searchItem" id="monthItem">
<select class="form-control" id="sMonth">
<%
For i = 0 To -5 Step -1
%>
<option value="<%= Left(DateAdd("M", i, date), 7)%>" <%= iif(sMonth = Left(DateAdd("M", i, date), 7),"selected", "") %>><%= Left(DateAdd("M", i, date), 7)%></option>
<%
Next
%>
</select>
<div class="input-group-prepend ml-2">
<span class="input-group-text bg-cyan">담당자메일</span>
</div>
<input type="text" class="form-control border" id="searchType_filter" value="<%= userEmail %>" placeholder="담당자메일을 입력해주세요" />
<div class="input-group-append">
<button class="btn btn-primary p-0" type="button" id="searchFilterBtn"><i class="fas fa-search"></i></button>
</div>
</div>
<div class="input-group searchItem d-none" id="paperItem">
<span class="flex-fill">
<div class="input-group">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">작성일자</span>
</div>
<input type="text" class="form-control border" id="p-WriteDate" value="" style="cursor:pointer;" readonly>
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">사업자번호</span>
</div>
<input type="text" class="form-control border" id="p-CorpNum" value="" maxlength="12">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">상호</span>
</div>
<input type="text" class="form-control border" id="p-CorpName" value="">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">대표자명</span>
</div>
<input type="text" class="form-control border" id="p-CEOName" value="">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">담당자메일</span>
</div>
<input type="text" class="form-control border" id="p-WriteUser" value="<%= Session("User_Mail")%>" readonly>
</div>
<div class="input-group mt-1">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">대표품목명</span>
</div>
<input type="text" class="form-control border" id="p-Items" value="">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">합계금액</span>
</div>
<input type="text" class="form-control border" id="p-TotalAmount" value="0" readonly="">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">공급가액</span>
</div>
<input type="text" class="form-control border" id="p-AmountTotal" value="0">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">세액</span>
</div>
<input type="text" class="form-control border" id="p-TaxTotal" value="0">
<div class="input-group-prepend ml-1">
<span class="input-group-text bg-lightblue justify-content-center">회사</span>
</div>
<select class="form-control" id="p-Company">
<option value="KRi">KRi</option>
<option value="KRc">KRc</option>
<option value="KRd">KRd</option>
</select>
</div>
</span>
<div class="input-group-addon ml-1">
<button class="btn btn-success px-2 h-100" type="button" id="addPaperTax">등<br>록</button>
</div>
</div>
</div>
</div>
<div class="row row-0 mt-0">
<div class="col-12">
<table class="table table-sm table-sm2 table-bordered table-head tr-colors mt-2" id="resultTb" style="table-layout:fixed;font-size:12px;">
<colgroup>
<col width="35px" />
<col width="35px" />
<col width="85px" />
<col width="85px" />
<col width="85px" />
<col width="100px" />
<col width="120px" />
<col width="100px" />
<col width="" />
<col width="100px" />
<col width="86px" />
<col width="86px" />
<col width="86px" />
<col width="86px" />
</colgroup>
<thead>
<tr>
<td class="text-center">선택</td>
<td class="text-center">회사</td>
<td class="text-center">작성일자</td>
<td class="text-center">발급일자</td>
<td class="text-center">전송일자</td>
<td class="text-center">사업자번호</td>
<td class="text-center">상호</td>
<td class="text-center">대표자명</td>
<td class="text-center">대표품목명</td>
<td class="text-center">담당자메일</td>
<td class="text-center">합계금액</td>
<td class="text-center">공급가액</td>
<td class="text-center">세액</td>
<td class="text-center">작성가능금액</td>
<td class="d-none">작성가능부가세</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<nav aria-label="Page navigation" id="pageNav">
</nav>
</div>
</div>
</div>
</div>
</div>
<!-- /.content -->
<%
%>
<!-- REQUIRED SCRIPTS -->
<script>
var Company = "<%=Company%>";
var MonthlyTaxLIst = [];
var countPerPage = 10;
var taxHistory = [];
function taxInvoiceSetting(NTSSendKey){
var tmpTaxHistory;
$.ajax({
url: "/barobill/baro_api.asp",
type: "POST",
async: false,
data: {"command":"GetTaxInvoiceHistory", "NTSConfirmNum":NTSSendKey},
success: function(ret){
tmpTaxHistory = JSON.parse(ret);
}
});
var taxInfo = JSON.parse(ajaxResponse);
var tmpHTML = "";
var tmpAmount = tmpTaxHistory.length > 0 ? taxInfo.AmountTotal - +tmpTaxHistory[0].AmountTotal : +taxInfo.AmountTotal;
var tmpTax = tmpTaxHistory.length > 0 ? taxInfo.TaxTotal - +tmpTaxHistory[0].TaxTotal : +taxInfo.TaxTotal;
var tmpBgClass = "";
if(tmpAmount <= 0){
tmpBgClass = "bg-danger";
}else if((tmpAmount + tmpTax) != +taxInfo.TotalAmount){
tmpBgClass = "bg-blue";
}
tmpHTML += "<tr style='cursor:pointer;' class='taxTr' data-sendkey='"+ NTSSendKey +"'>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'><input type='radio' name='selTax' value='"+ NTSSendKey +"' data-deal='"+ taxInfo.TaxType +"' "+ (tmpAmount <= 0 ? "disabled" : "") +"/></td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ Company.replace("kr", "KR") +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ left(taxInfo.WriteDate, 8).replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'></td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'></td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ taxInfo.InvoicerParty.CorpNum.replace(/(\d{3})(\d{2})(\d{5})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ taxInfo.InvoicerParty.CorpName +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ taxInfo.InvoicerParty.CEOName +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ taxInfo.TaxInvoiceTradeLineItems[0].Name +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ taxInfo.InvoiceeParty.Email +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ commify(taxInfo.TotalAmount) +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ commify(taxInfo.AmountTotal) +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ commify(taxInfo.TaxTotal) +"</td>";
tmpHTML += "<td class='py-3 text-center "+ tmpBgClass +"'>"+ commify(tmpAmount) +"</td>";
tmpHTML += "<td class='d-none'>"+ commify(tmpTax) +"</td>";
tmpHTML += "</tr>";
$("#resultTb > tbody").html(tmpHTML);
$(".taxTr > td:nth-child(n + 2)").on("click", function(){
var NTSConfirmNum = $(this).parent().data("sendkey");
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetTaxInvoicePopUpURLNK", "NTSConfirmNum":NTSConfirmNum, "Company":Company}, "", "POST", "taxInvoiceView()");
});
/*
NTSSendKey // 국세청승인번호 : "2022080414010700p0000000"
taxInfo.InvoicerParty.CorpName // 상호 : "홈택스 연동 가상매입처" *************
taxInfo.InvoicerParty.CorpNum // 사업자번호 : "0000000000" *************
taxInfo.WriteDate // 작성일자 : "20220804" *************
taxInfo.AmountTotal // 공급가액 : "100000" *************
taxInfo.TaxTotal // 세액 : "10000" *************
taxInfo.TotalAmount // 합계금액 : "110000" *************
*/
}
function taxInvoiceView(){
window.open(ajaxResponse, "", "left=150, top=150, menubar=no, location=no, status=no, toolbar=no, width=960, height=800, scrollbars=yes ,resizable=no");
}
function monTaxInvoiceSetting(cPage){
<% If Session("N_depart") <> "M" Then %>
if($("#searchType_filter").val().trim().length < 3) {
alert("3글자 이상 입력 후 검색해주세요.");
return false;
}
<% End If %>
var sMonth = $("#sMonth").children("option:selected").val();
var tmpHTML = "";
var filterMail = $("#searchType_filter").val();
var tmpFilterList = $.grep(MonthlyTaxLIst, function(o, i){ return o.InvoiceeEmail.indexOf(filterMail) > -1; });
var taxList = $.grep(tmpFilterList, function(o, i){ return i >= (cPage-1) * countPerPage && i < cPage * countPerPage; });
$.each(taxList, function(i, obj){
var tmpTaxHistory = $.grep(taxHistory, function(o, i){ return o.taxNum == obj.NTSSendKey; });
var tmpAmount = tmpTaxHistory.length > 0 ? obj.AmountTotal - +tmpTaxHistory[0].AmountTotal : +obj.AmountTotal;
var tmpTax = tmpTaxHistory.length > 0 ? obj.TaxTotal - +tmpTaxHistory[0].TaxTotal : +obj.TaxTotal;
var tmpBgClass = "";
if(tmpAmount <= 0){
tmpBgClass = "bg-danger";
}else if((tmpAmount + tmpTax) != +obj.TotalAmount){
tmpBgClass = "bg-blue";
}
tmpHTML += "<tr style='cursor:pointer;' class='taxTr' data-sendkey='"+ obj.NTSSendKey +"'>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'><input type='radio' name='selTax' value='"+ obj.NTSSendKey +"' data-deal='"+ obj.TaxType +"' "+ (tmpAmount <= 0 ? "disabled" : "") +"/></td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ Company.replace("kr", "KR") +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ left(obj.WriteDate, 8).replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ left(obj.IssueDT, 8).replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ left(obj.NTSSendDT, 8).replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.InvoicerCorpNum.replace(/(\d{3})(\d{2})(\d{5})/, '$1-$2-$3') +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.InvoicerCorpName +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.InvoicerCEOName +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.ItemName +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.InvoiceeEmail +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.TotalAmount) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.AmountTotal) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.TaxTotal) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(tmpAmount) +"</td>";
tmpHTML += "<td class='d-none'>"+ commify(tmpTax) +"</td>";
/*
obj.NTSSendKey // 국세청승인번호 : "2022080414010700p0000000" *************
obj.InvoiceeEmail // 이메일 : dskim@kric.com
obj.InvoicerCorpName // 상호 : "홈택스 연동 가상매입처" *************
obj.InvoicerCorpNum // 사업자번호 : "0000000000" *************
obj.InvoicerCEOName // 대표자명 : "홍길동"
obj.WriteDate // 작성일자 : "20220804" *************
obj.IssueDT // 발급일자 : "20220804140107"
obj.NTSSendDT // 전송날짜 : "20220804140107"
obj.ItemName // 대표 품목 : "가상 매입"
obj.AmountTotal // 공급가액 : "100000" *************
obj.TaxTotal // 세액 : "10000" *************
obj.TotalAmount // 합계금액 : "110000" *************
*/
tmpHTML += "</tr>";
});
if(taxList.length == 0){
tmpHTML = "<tr><td class='text-center py-3' colspan='14'>조회 결과가 없습니다</td></tr>";
}
$("#resultTb > tbody").html(tmpHTML);
$(".taxTr > td:nth-child(n + 2)").on("click", function(){
var NTSConfirmNum = $(this).parent().data("sendkey");
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetTaxInvoicePopUpURLNK", "NTSConfirmNum":NTSConfirmNum, "Company":Company}, "", "POST", "taxInvoiceView()");
});
paginationSetting(cPage, Math.ceil(tmpFilterList.length / countPerPage));
}
function paginationSetting(cPage, maxPage){
$("#pageNav").html("");
if(maxPage == 0) return false;
var tmpHTML = "<ul class='pagination justify-content-center'>";
tmpHTML += "<li class='page-item "+(cPage == "1" ? "disabled" : "")+"'><a class='page-link' href='#' data-page='-'><i class='fas fa-chevron-left'></i></a></li>";
for(var i=1; i<=maxPage; i++){
tmpHTML += "<li class='page-item " + (i == cPage ? "active" : "") + "'><a class='page-link' href='#' data-page='" + i + "'>" + i + "</a></li>";
}
tmpHTML += "<li class='page-item "+(cPage == maxPage ? "disabled" : "")+"'><a class='page-link' href='#' data-page='+'><i class='fas fa-chevron-right'></i></a></li>";
$("#pageNav").html(tmpHTML);
}
function getMonthlyTaxs(sMonth){
MonthlyTaxLIst = [];
taxHistory = [];
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetMonthlyTaxInvoicePurchaseList", "sMonth":sMonth, "sPage":"1", "Company":Company}, "", "POST", "settingMonthlyTaxList('"+ sMonth +"', '1')");
$.ajax({
url: "/barobill/baro_api.asp",
type: "POST",
async: false,
data: {"command":"GetTaxInvoiceHistory", "sMonth":sMonth},
success: function(ret){
taxHistory = JSON.parse(ret);
}
});
}
function settingMonthlyTaxList(sMonth, cPage){
ajaxResponse = ajaxResponse.replace(/"ItemName":"([^"]*)(["]+)([^"]*)",/g, function(match, value) {
var fixedValue = match.replace('"ItemName":"','');
fixedValue = fixedValue.replace('",','');
fixedValue = fixedValue.replace(/"/g," ");
fixedValue = '"ItemName":"'+fixedValue+'",';
return fixedValue;
});
var resultJson = JSON.parse(ajaxResponse.replace(/("ItemName":")(\d+)"/g, '$1$2'));
MonthlyTaxLIst = MonthlyTaxLIst.concat(resultJson.SimpleTaxInvoiceExList);
if(+resultJson.CurrentPage <= +resultJson.MaxPageNum){
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetMonthlyTaxInvoicePurchaseList", "sMonth":sMonth, "sPage":(+cPage+1), "Company":Company}, "", "POST", "settingMonthlyTaxList('"+ sMonth +"', '"+ (+cPage+1) +"')");
}
}
function getPaperTaxList(){
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetPaperTax"}, "", "POST", "settingPaperTaxList('1')");
}
function settingPaperTaxList(cPage){
var resultJson = JSON.parse(ajaxResponse);
$.ajax({
url: "/barobill/baro_api.asp",
type: "POST",
async: false,
data: {"command":"GetTaxInvoiceHistory", "NTSConfirmNum":"K%"},
success: function(ret){
taxHistory = JSON.parse(ret);
}
});
var tmpHTML = "";
var taxList = $.grep(resultJson, function(o, i){ return i >= (cPage-1) * countPerPage && i < cPage * countPerPage; });
$.each(taxList, function(i, obj){
var tmpTaxHistory = $.grep(taxHistory, function(o, i){ return o.taxNum == obj.paperTaxNum; });
var tmpAmount = tmpTaxHistory.length > 0 ? obj.AmountTotal - +tmpTaxHistory[0].AmountTotal : +obj.AmountTotal;
var tmpTax = tmpTaxHistory.length > 0 ? obj.TaxTotal - +tmpTaxHistory[0].TaxTotal : +obj.TaxTotal;
var tmpBgClass = "";
if(tmpAmount <= 0){
tmpBgClass = "bg-danger";
}else if((tmpAmount + tmpTax) != +obj.TotalAmount){
tmpBgClass = "bg-blue";
}
tmpHTML += "<tr style='cursor:pointer;' class='taxTr' data-id='"+ obj.id +"'>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'><input type='radio' name='selTax' value='"+ obj.paperTaxNum +"' data-deal='1' "+ (tmpAmount <= 0 ? "disabled" : "") +"/></td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.Company.replace("kr", "KR") +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.WriteDate +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'></td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'></td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.CorpNum +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.CorpName +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.CEOName +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.Items +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ obj.WriteUser +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.TotalAmount) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.AmountTotal) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(obj.TaxTotal) +"</td>";
tmpHTML += "<td class='py-2 text-center "+ tmpBgClass +"'>"+ commify(tmpAmount) + (tmpTax != 0 && tmpAmount != +obj.AmountTotal ? "<br>" + commify(tmpTax) : "") +"</td>";
tmpHTML += "</tr>";
});
if(resultJson.length == 0){
tmpHTML = "<tr><td class='text-center py-3' colspan='14'>조회 결과가 없습니다</td></tr>";
}
$("#resultTb > tbody").html(tmpHTML);
paginationSetting(cPage, Math.ceil(resultJson.length / countPerPage));
}
function paperTaxComplete(divi){
if(divi == "1"){ // 저장 완료
if(ajaxResponse == "1"){
alert("종이세금계산서 작성이 완료 되었습니다.");
getPaperTaxList();
}
}else if(divi == "2"){ // 삭제 완료
if(ajaxResponse == "1"){
alert("종이세금계산서 삭제가 완료 되었습니다.");
getPaperTaxList();
}
}
if(ajaxResponse == "0"){
alert("에러가 발생하였습니다.\n담당자에게 문의해주세요.");
}
}
$(function(){
cutmenu();
$("#p-WriteDate").datepicker();
$("input[name='searchType']").on("click", function(){
$(".searchItem").addClass("d-none");
$("#deleteBtn").addClass("d-none");
$("#NTSConfirmNum").val("");
$("#resultTb > tbody").html("");
$("#pageNav").html("");
if($(this).val() == "num"){
$("#numItem").removeClass("d-none");
}else if($(this).val() == "month"){
$("#monthItem").removeClass("d-none");
$("#sMonth").trigger("change");
}else if($(this).val() == "paper"){
$("#paperItem").removeClass("d-none");
$("#deleteBtn").removeClass("d-none");
getPaperTaxList();
}
});
$("#searchBtn").on("click", function(){
var NTSConfirmNum = $("#NTSConfirmNum").val();
if($.trim(NTSConfirmNum) == ""){
alert("국세청 승인번호를 입력해주세요.");
$("#NTSConfirmNum").val("");
return false;
}
ajaxCallJson("/barobill/baro_api.asp", {"command":"GetTaxInvoiceNK", "NTSConfirmNum":NTSConfirmNum, "Company":Company}, "", "POST", "taxInvoiceSetting('" + NTSConfirmNum + "')");
});
$("#NTSConfirmNum").on("keydown", function(e){
if(e){
var keycode = e.which ? e.which : e.keyCode;
if(keycode == 13){
$("#searchBtn").trigger("click");
}
}
});
$("#searchType_filter").on("keydown", function(e){
if(e){
var keycode = e.which ? e.which : e.keyCode;
if(keycode == 13){
$("#searchFilterBtn").click();
}
}
});
$("#sMonth").on("change", function(){
var sMonth = $("#sMonth").children("option:selected").val();
getMonthlyTaxs(sMonth);
});
$("#searchFilterBtn").on("click", function(){
monTaxInvoiceSetting(1);
});
$("#p-CorpNum").on("keyup", function(){
$(this).val(autoHypenPhoneNum($(this).val()));
});
$("#p-AmountTotal, #p-TaxTotal").on("keyup", function(){
var sum = +($("#p-AmountTotal").val().replace(/[^0-9]/g, '') || "0") + +($("#p-TaxTotal").val().replace(/[^0-9]/g, '') || "0");
$(this).val(commify(+($(this).val().replace(/[^0-9]/g, '') || "0")));
$("#p-TotalAmount").val(commify(sum));
});
<% If NTSConfirmNum <> "" Then %>
$("#searchType_num").click();
$("#NTSConfirmNum").val("<%=NTSConfirmNum%>");
$("#searchBtn").trigger("click");
<% Else %>
$("#searchType_month").click();
setTimeout(function(){
$("#searchFilterBtn").click();
}, 0);
<% End If %>
$(document).on("click", ".page-link", function(){
var page = $(this).data("page");
if(page == "-" || page == "+"){
page = eval($(".page-item.active > .page-link").data("page") + page + "1");
}
if($("input[name='searchType']:checked").val() == "month"){
monTaxInvoiceSetting(page);
}else if($("input[name='searchType']:checked").val() == "paper"){
settingPaperTaxList(page);
}
});
$("#addPaperTax").on("click", function(){
var chk = true;
var params = {};
$("#paperItem").find("input,select").each(function(){
var thisVal = "";
if($(this)[0].nodeName == "SELECT"){
thisVal = $(this).children("option:selected").val();
}else{
thisVal = $(this).val();
}
thisVal = (thisVal || "").trim();
if(thisVal == ""){
chk = false;
alert($(this).prev().children().text() + " 항목을 입력해주세요.");
return false;
}else if($(this).attr("id") == "p-AmountTotal" && thisVal == "0"){
chk = false;
alert("공급가액을 입력해주세요.");
return false;
}
params[$(this).attr("id").replace("p-", "")] = thisVal;
});
if(!chk) return false;
if(checkCompRegNum($("#p-CorpNum").val()) == false){
alert("사업자번호가 유효하지 않습니다.");
return false;
}
params.AmountTotal = params.AmountTotal.replace(/,/g, '');
params.TaxTotal = params.TaxTotal.replace(/,/g, '');
params.TotalAmount = params.TotalAmount .replace(/,/g, '');
params.CorpName = encodeURIComponent(params.CorpName);
params.CEOName = encodeURIComponent(params.CEOName);
params.Items = encodeURIComponent(params.Items);
params.paperTaxNum = "K" + new Date().format("yyyyMMddHHmmss") + randomRange(1, 999).zf(3) + "_" + randomRange(1, 99999).zf(5); // 랜덤생성
ajaxCallJson("/barobill/baro_api.asp", Object.assign({"command":"SetPaperTax"}, params), "", "POST", "paperTaxComplete('1')");
});
$("#deleteBtn").on("click", function(){
if($("input[name=selTax]:checked").length == 0){
alert("삭제할 세금계산서를 선택해주세요.");
return false;
}else{
if(!confirm("선택한 세금계산서를 삭제하시겠습니까?")){
return false;
}
}
var targetTr = $("input[name=selTax]:checked").parent().parent();
var tmpId = $(targetTr).data("id");
if($(targetTr).children("td").eq(9).text() != "<%= Session("User_Mail")%>"){
alert("본인이 등록한 세금계산서만 삭제 가능합니다.");
return false;
}
if($(targetTr).children("td").eq(0).hasClass("bg-danger") || $(targetTr).children("td").eq(0).hasClass("bg-blue")){
alert("해당 세금계산서로 작성된 지출결의서가 존재합니다.");
return false;
}
ajaxCallJson("/barobill/baro_api.asp", {"command":"DeletePaperTax", "id":tmpId}, "", "POST", "paperTaxComplete('2')");
});
$("#selectBtn").on("click", function(){
if($("input[name=selTax]:checked").length == 0){
alert("세금계산서를 선택해주세요.");
return false;
}else{
if(!confirm("선택한 세금계산서 정보로\n지출결의서를 작성하시겠습니까?")){
return false;
}
}
var taxTr = $("input[name=selTax]:checked").parent().parent();
var NTSSendKey = $("input[name=selTax]:checked").val();
var TaxType = $("input[name=selTax]:checked").data("deal");
var CompName = $(taxTr).children("td").eq(1).text();
var InvoicerCorpName = $(taxTr).children("td").eq(6).text();
var InvoicerCorpNum = $(taxTr).children("td").eq(5).text();
var WriteDate = $(taxTr).children("td").eq(2).text();
var AmountTotal = $(taxTr).children("td").eq(11).text();
var TaxTotal = $(taxTr).children("td").eq(12).text();
var TotalAmount = $(taxTr).children("td").eq(10).text();
var ItemName = $(taxTr).children("td").eq(8).text();
var WriteAbleAmount = $(taxTr).children("td").eq(13).text();
var WriteAbleTax = $(taxTr).children("td").eq(14).text();
//console.log(NTSSendKey,InvoicerCorpName,InvoicerCorpNum,WriteDate,AmountTotal,TaxTotal,TotalAmount);
$(opener.document).find("input[name=expence_num]").val(NTSSendKey);
$(opener.document).find("input[name=k_company]").val(CompName);
$(opener.document).find("input[name=expence_company]").val(InvoicerCorpName);
$(opener.document).find("input[name=expence_company]").attr("readonly", true);
$(opener.document).find("input[name=expence_company_num]").val(InvoicerCorpNum);
$(opener.document).find("input[name=expence_date]").val(WriteDate);
$(opener.document).find("input[name=expence_date]").off("focus");
$(opener.document).find("input[name=expence_taxtype]").val(TaxType);
$(opener.document).find("input[name=expence_item]").val(ItemName);
$(opener.document).find("input[name=expence_money]").val("0");
$(opener.document).find("input[name=expence_vat]").val("0");
$(opener.document).find("input[name=expence_sum]").val("0");
if(WriteAbleAmount == AmountTotal){
opener.AmountTotal = +(AmountTotal.replace(/,/gi, ''));
opener.TaxTotal = +(TaxTotal.replace(/,/gi, ''));
opener.TotalAmount = +(TotalAmount.replace(/,/gi, ''));
if($(opener.document).find("#boolgong").prop("checked") == true){
if($(opener.document).find("#writeAbleDiv").length == 0){
$(opener.document).find("input[name=expence_money]").val(TotalAmount);
$(opener.document).find("input[name=expence_vat]").val("0");
$(opener.document).find("input[name=expence_sum]").val(TotalAmount);
}
opener.MaxAmountTotal = +(TotalAmount.replace(/,/gi, ''));
opener.MaxTaxTotal = 0;
}else{
if($(opener.document).find("#writeAbleDiv").length == 0){
$(opener.document).find("input[name=expence_money]").val(AmountTotal);
$(opener.document).find("input[name=expence_vat]").val(TaxTotal);
$(opener.document).find("input[name=expence_sum]").val(TotalAmount);
}
opener.MaxAmountTotal = +(AmountTotal.replace(/,/gi, ''));
opener.MaxTaxTotal = +(TaxTotal.replace(/,/gi, ''));
}
}else{
if($(opener.document).find("#writeAbleDiv").length == 0){
$(opener.document).find("input[name=expence_money]").val(WriteAbleAmount);
$(opener.document).find("input[name=expence_vat]").val(WriteAbleTax);
$(opener.document).find("input[name=expence_sum]").val(commify(+(WriteAbleAmount.replace(/,/gi, '')) + +(WriteAbleTax.replace(/,/gi, ''))));
}
opener.AmountTotal = +(WriteAbleAmount.replace(/,/gi, ''));
opener.TaxTotal = +(WriteAbleTax.replace(/,/gi, ''));
opener.TotalAmount = +(WriteAbleAmount.replace(/,/gi, '')) + +(WriteAbleTax.replace(/,/gi, ''));
opener.MaxAmountTotal = +(WriteAbleAmount.replace(/,/gi, ''));
opener.MaxTaxTotal = +(WriteAbleTax.replace(/,/gi, ''));
}
if($(opener.document).find("#writeAbleDiv").length == 0){
$(opener.document).find("input[name=expence_vat]").attr("readonly", true);
opener.check_comma($(opener.document).find("input[name=expence_money]").val(), '1');
}else{
$(opener.document).find("#MaxAmountTotal").html(commify(opener.MaxAmountTotal));
$(opener.document).find("#MaxTaxTotal").html(commify(opener.MaxTaxTotal));
opener.check_comma('', '3', 1);
}
$(opener.document).find("select[name=expence_way]").hide();
$(opener.document).find("select[name=expence_way]").next().remove();
$(opener.document).find("select[name=expence_way]").after("<span>세금계산서</span>");
self.close();
});
});
function autoHypenPhoneNum(str){
str = str.replace(/[^0-9]/g, '');
var tmp = '';
if( str.length < 4){
return str;
}else if(str.length < 7){
tmp += str.substr(0, 3);
tmp += '-';
tmp += str.substr(3);
return tmp;
}else{
tmp += str.substr(0, 3);
tmp += '-';
tmp += str.substr(3, 2);
tmp += '-';
tmp += str.substr(5);
return tmp;
}
return str;
}
</script>
</div>
<!-- /.content-wrapper -->
<!-- #include virtual = "include/footer.asp" -->