세금계산서 작업

This commit is contained in:
lch 2021-04-28 09:23:25 +00:00
parent 33c85d1072
commit 21b3db154b
5 changed files with 180 additions and 69 deletions

View File

@ -801,7 +801,8 @@ namespace NP.BO.Controllers
var result = PopbillService.GetTaxinvoice(payTax);
if (result.IsSuccess)
{
ViewBag.Taxinvoice = result.Data;
ViewBag.Taxinvoice = result.Data;
ViewBag.TaxinvoiceInfo = PopbillService.GetTaxinvoiceInfo(payTax).Data;
}
}
#endregion

View File

@ -1,7 +1,10 @@
@model NP.Model.VMCRoom
@using NP.Base.Popbill
@using Popbill.Taxinvoice;
@model NP.Model.VMCRoom
@{
var t = Model.PayTaxes.First();
var taxinvoice = ViewBag.Taxinvoice;
var taxinvoice = (Taxinvoice)ViewBag.Taxinvoice;
var taxinvoiceInfo = (TaxinvoiceInfo)ViewBag.TaxinvoiceInfo;
}
<div>
<ul class="pagination pagination-md" style="margin: 0;">
@ -137,6 +140,10 @@
<th>문서번호</th>
<td><input type="text" class="form-control dev" name="taxinvoice.invoicerMgtKey" readonly value="@taxinvoice.invoicerMgtKey" /></td>
</tr>
<tr>
<th style="height:43px;">세금계산서 상태</th>
<td colspan="3"><spna style="color:red;">@(taxinvoiceInfo != null ? PopbillService.GetTaxinvoiceState(taxinvoiceInfo.stateCode) : "")</spna></td>
</tr>
</tbody>
</table>
</section>
@ -179,7 +186,7 @@
</tr>
<tr>
<th>사업장주소</th>
<td colspan="3"><input type="text" class="form-control dev" name="asaddr" readonly="readonly" value="@t.asaddr" /></td>
<td colspan="3"><input type="text" class="form-control dev" name="asaddr" value="@t.asaddr" /></td>
</tr>
<tr>
<th>첨부파일</th>
@ -195,8 +202,8 @@
<tr>
<th>영수구분</th>
<td colspan="3">
<label><input type="radio" name="isreceipt" value="0" @(t.isreceipt == 0 ? "checked" : "") disabled style="vertical-align: bottom" /> 청구</label>
<label><input type="radio" name="isreceipt" value="1" @(t.isreceipt == 0 ? "" : "checked") disabled style="vertical-align: bottom" /> 영수</label>
<label><input type="radio" name="isreceipt" value="0" @(t.isreceipt == 0 ? "checked" : "") style="vertical-align: bottom" /> 청구</label>
<label><input type="radio" name="isreceipt" value="1" @(t.isreceipt == 0 ? "" : "checked") style="vertical-align: bottom" /> 영수</label>
</td>
</tr>
<tr>
@ -212,6 +219,7 @@
<input type="hidden" name="mgtkey" value="@t.mgtkey" />
<input type="hidden" name="iscancel" value="@t.iscancel" />
<input type="hidden" name="taxamt" value="@t.taxamt" />
<input type="hidden" name="fgno" value="@t.fgno" />
<div class="text-center">
@if (t.iscancel == null || t.iscancel.Value != 1)
{
@ -219,25 +227,31 @@
if (string.IsNullOrEmpty(t.mgtkey))
{
<a href="#" class="btn btn-primary" onclick="save();">저장</a>
<a href="#" class="btn btn-success" onclick="tempsave();">임시저장</a>
<a href="#" class="btn btn-success" onclick="registIssue();">계산서 즉시발행</a>
<a href="#" class="btn btn-danger" onclick="cancelIssue();">발행취소</a>
if (Model.PayTaxItem.First().payoktime != null)
{
<a href="#" class="btn btn-success" onclick="tempsave();">임시저장</a>
<a href="#" class="btn btn-success" onclick="registIssue();">계산서 즉시발행</a>
}
}
else
{
if (string.IsNullOrEmpty(taxinvoice.ntsconfirmNum))
{
<a href="#" class="btn btn-primary" onclick="save();">저장</a>
<a href="#" class="btn btn-success" onclick="tempsave();">임시저장</a>
<a href="#" class="btn btn-success" onclick="view();">미리보기</a>
<a href="#" class="btn btn-success" onclick="Issue();">계산서 즉시발행</a>
<a href="#" class="btn btn-danger" onclick="cancelIssue();">발행취소</a>
if (Model.PayTaxItem.First().payoktime != null)
{
<a href="#" class="btn btn-success" onclick="tempsave();">임시저장</a>
<a href="#" class="btn btn-success" onclick="view();">미리보기</a>
<a href="#" class="btn btn-success" onclick="Issue();">계산서 즉시발행</a>
}
}
else
{
<a href="#" class="btn btn-success" onclick="view();">계산서조회</a>
}
}
<a href="#" class="btn btn-danger" onclick="cancelIssue();">발행취소</a>
}
<a href="#" class="btn btn-default" onclick="$('#dform').attr('action', '/croom/tax');golist();">목록</a>
</div>
@ -305,7 +319,7 @@
}
function cbtempsave() {
if (capResult.code == 1000) {
msg("임시저장되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');");
msg("임시저장되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');");
} else if (capResult.code == -1) {
msg("이미 발행요청건이 존재합니다.");
} else {
@ -315,7 +329,7 @@
msgadmin();
}
}
}
}
function cancelIssue() {
if (confirm("발행을 취소하시겠습니까?")) {
$("input[name='iscancel']").val(1);
@ -356,7 +370,7 @@
cap("/acommon/paytaxregistissue", "sform", "cbregistIssue");
}
}
function cbregistIssue() {
function cbregistIssue() {
if (capResult.code == 1000) {
msg("즉시발행되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');");
} else if (capResult.code == -1) {
@ -367,7 +381,7 @@
} else {
msgadmin();
}
}
}
}
function view() {
cap("/acommon/paytaxview", "sform", "cbview");

View File

@ -11,6 +11,7 @@ using NP.Base.ENUM;
using System.Net.Http;
using XPayClientNet;
using NP.Base.Popbill;
namespace NP.Base.Controllers
{
@ -799,7 +800,7 @@ namespace NP.Base.Controllers
{
var payItems = Dao.Get<PayItem>("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", payTax.taxno } });
var result = Popbill.PopbillService.TempSave(payTax, payItems);
var result = Popbill.PopbillService.TempSave(Dao, payTax, payItems);
if (result.IsSuccess)
{
return JsonOK(result.Code);
@ -879,7 +880,7 @@ namespace NP.Base.Controllers
{
var payItems = Dao.Get<PayItem>("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", payTax.taxno } });
var result = Popbill.PopbillService.RegistIssue(payTax, payItems);
var result = Popbill.PopbillService.RegistIssue(Dao, payTax, payItems);
if (result.IsSuccess)
{
return JsonOK(result.Code);
@ -910,21 +911,21 @@ namespace NP.Base.Controllers
var taxinvoice = Popbill.PopbillService.GetTaxinvoice(payTax).Data;
if (!string.IsNullOrEmpty(taxinvoice.ntsconfirmNum))
{
if (Dao.Save("cr.paytax.save", payTax) > 0)
var result = Popbill.PopbillService.CancelIssue(payTax.mgtkey);
if (result.IsSuccess)
{
var result = Popbill.PopbillService.CancelIssue(payTax.mgtkey);
if (result.IsSuccess)
{
return JsonOK(result.Code);
}
else
{
return JsonError(JSONCode.Error, result.Message, result);
}
return JsonOK(Dao.Save("cr.paytax.save", payTax));
}
else
{
return JsonOK(0);
#region
var taxinvoiceInfo = PopbillService.GetTaxinvoiceInfo(payTax).Data;
if (taxinvoiceInfo.stateCode == 600)
{
return JsonOK(Dao.Save("cr.paytax.save", payTax));
}
#endregion
return JsonError(JSONCode.Error, result.Message, result);
}
}
else

View File

@ -7,6 +7,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
namespace NP.Base.Popbill
@ -120,6 +121,49 @@ namespace NP.Base.Popbill
}
#endregion
#region
/// <summary>
/// 세금계산서 상태
/// </summary>
/// <param name="stateCode">상태코드</param>
/// <returns>상태</returns>
public static string GetTaxinvoiceState(int stateCode)
{
string state = string.Empty;
switch (stateCode)
{
case 100:
state = "임시저장";
break;
case 300:
state = "발행완료";
break;
case 301:
state = "전송전";
break;
case 302:
state = "전송대기";
break;
case 303:
state = "전송중";
break;
case 304:
state = "전송성공";
break;
case 305:
state = "전송실패";
break;
case 600:
state = "발행취소";
break;
default:
state = $"stateCode:{stateCode}";
break;
}
return state;
}
#endregion
#region
/// <summary>
/// 세금계산서 상세정보
@ -169,33 +213,104 @@ namespace NP.Base.Popbill
}
#endregion
#region
/// <summary>
/// 세금계산서 상태정보
/// </summary>
/// <param name="payTax">PayTax</param>
/// <param name="keyType">세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁</param>
/// <returns>Taxinvoice</returns>
public static Result<TaxinvoiceInfo> GetTaxinvoiceInfo(PayTax payTax, MgtKeyType keyType = MgtKeyType.SELL)
{
Result<TaxinvoiceInfo> result = new Result<TaxinvoiceInfo>();
try
{
result.Data = PopbillConfig.taxinvoiceService.GetInfo(PopbillConfig.CorpNum, keyType, payTax.mgtkey);
}
catch (PopbillException ex)
{
result.IsSuccess = false;
result.Code = ex.code;
result.Message = ex.Message;
Logger.TryError(ex.Message, ex);
}
return result;
}
#endregion
#region ()
/// <summary>
/// 세금계산서 파일등록(사업자등록증)
/// </summary>
/// <param name="Dao"></param>
/// <param name="payTax"></param>
/// <param name="keyType"></param>
/// <returns></returns>
public static Response AttachFile(CommonDao Dao, PayTax payTax, MgtKeyType keyType = MgtKeyType.SELL)
{
Response response = new Response();
if (payTax.fgno != null && payTax.fgno != 0)
{
IList<File> files = Dao.GetFiles(payTax.fgno.Value);
#region ()
if (files.Count > 0)
{
var attachedFiles = PopbillConfig.taxinvoiceService.GetFiles(PopbillConfig.CorpNum, keyType, payTax.mgtkey);
foreach (var attachedFile in attachedFiles)
{
response = PopbillConfig.taxinvoiceService.DeleteFile(PopbillConfig.CorpNum, keyType, payTax.mgtkey, attachedFile.attachedFile, PopbillConfig.UserID);
}
}
#endregion
#region #region ()
foreach (var file in files)
{
var filePath = HttpContext.Current.Server.MapPath(file.fullurl);
if (System.IO.File.Exists(filePath))
{
response = PopbillConfig.taxinvoiceService.AttachFile(PopbillConfig.CorpNum, keyType, payTax.mgtkey, filePath, PopbillConfig.UserID);
}
}
#endregion
}
return response;
}
#endregion
#region ()
/// <summary>
/// 세금계산서 임시저장(수정)
/// </summary>
/// <param name="Dao">CommonDao</param>
/// <param name="payTax">payTax</param>
/// <param name="payItems">payItems</param>
/// <param name="keyType">세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁</param>
/// <returns>mgtkey</returns>
/// <remarks>작성된 세금계산서 데이터를 팝빌에 저장합니다.</remarks>
public static Result<string> TempSave(PayTax payTax, IList<PayItem> payItems, MgtKeyType keyType = MgtKeyType.SELL)
public static Result<Response> TempSave(CommonDao Dao, PayTax payTax, IList<PayItem> payItems, MgtKeyType keyType = MgtKeyType.SELL)
{
Result<string> result = new Result<string>();
Result<Response> result = new Result<Response>();
try
{
Response response;
{
var taxinvoice = GetTaxinvoice(payTax, payItems).Data;
if (PopbillConfig.taxinvoiceService.CheckMgtKeyInUse(PopbillConfig.CorpNum, keyType, payTax.mgtkey))
{
response = PopbillConfig.taxinvoiceService.Update(PopbillConfig.CorpNum, keyType, payTax.mgtkey, taxinvoice, PopbillConfig.UserID);
result.Data = PopbillConfig.taxinvoiceService.Update(PopbillConfig.CorpNum, keyType, payTax.mgtkey, taxinvoice, PopbillConfig.UserID);
}
else
{
response = PopbillConfig.taxinvoiceService.Register(PopbillConfig.CorpNum, taxinvoice);
result.Data = PopbillConfig.taxinvoiceService.Register(PopbillConfig.CorpNum, taxinvoice);
}
result.Data = payTax.mgtkey;
result.Code = response.code;
result.Message = response.message;
if (result.Data.code == 1)
{
AttachFile(Dao, payTax, keyType);
}
result.Code = result.Data.code;
result.Message = result.Data.message;
}
catch (PopbillException ex)
{
@ -267,53 +382,31 @@ namespace NP.Base.Popbill
}
#endregion
#region
/// <summary>
/// 세금계산서 삭제 (국세청으로 전송되지 않은 세금계산서를 삭제합니다.)
/// </summary>
/// <param name="mgtkey">파트너가 할당한 문서번호</param>
/// <param name="keyType">세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁</param>
/// <returns>IssueResponse</returns>
/// <remarks>국세청으로 전송되지 않은 세금계산서를 삭제합니다.</remarks>
public static Result<Response> Delete(string mgtkey, MgtKeyType keyType = MgtKeyType.SELL)
{
Result<Response> result = new Result<Response>();
try
{
result.Data = PopbillConfig.taxinvoiceService.Delete(PopbillConfig.CorpNum, keyType, mgtkey);
result.Code = result.Data.code;
result.Message = result.Data.message;
}
catch (PopbillException ex)
{
result.IsSuccess = false;
result.Code = ex.code;
result.Message = ex.Message;
Logger.TryError(ex.Message, ex);
}
return result;
}
#endregion
#region
/// <summary>
/// 세금계산서 즉시 발행
/// </summary>
/// <param name="Dao">Dao</param>
/// <param name="payTax">payTax</param>
/// <param name="payItems">payItems</param>
/// <param name="forceIssue">지연발행 가능여부</param>
/// <param name="memo">메모</param>
/// <returns>IssueResponse</returns>
/// <remarks>작성된 세금계산서 데이터를 팝빌에 저장과 동시에 발행(전자서명)하여 "발행완료" 상태로 처리합니다.</remarks>
public static Result<IssueResponse> RegistIssue(PayTax payTax, IList<PayItem> payItems, bool forceIssue = false, string memo = "")
public static Result<IssueResponse> RegistIssue(CommonDao Dao, PayTax payTax, IList<PayItem> payItems, MgtKeyType keyType = MgtKeyType.SELL, bool forceIssue = false, string memo = "")
{
Result<IssueResponse> result = new Result<IssueResponse>(); ;
try
{
var taxinvoice = GetTaxinvoice(payTax, payItems).Data;
var taxinvoice = GetTaxinvoice(payTax, payItems, keyType).Data;
result.Data = PopbillConfig.taxinvoiceService.RegistIssue(PopbillConfig.CorpNum, taxinvoice, forceIssue, memo);
result.Code = result.Data.code;
result.Message = result.Data.message;
if (result.Data.code == 1)
{
AttachFile(Dao, payTax, keyType);
}
}
catch (PopbillException ex)
{

View File

@ -1331,7 +1331,9 @@
,email=HEX(AES_ENCRYPT(#email#, <include refid="sql.digest"></include>))
,taxdate=#taxdate#
,taxinfo=#taxinfo#
,isreceipt=#isreceipt#
,iscancel=#iscancel#
,asaddr=#asaddr#
,mgtkey=#mgtkey#
where taxno=#taxno#
</update>