From fa2df36c09e3db2bf2bfdb4db56e5abe6f205261 Mon Sep 17 00:00:00 2001 From: lch Date: Mon, 5 Jul 2021 05:15:14 +0000 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=A5=98=EC=88=98=EC=A0=95=20:=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=EC=84=9C=20=EC=A6=89=EC=8B=9C=EB=B0=9C?= =?UTF-8?q?=ED=96=89=EC=8B=9C=20=EC=B2=A8=EB=B6=80=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EB=B0=9C=ED=96=89=20?= =?UTF-8?q?=ED=9B=84=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=98=A4=EB=A5=98=EA=B0=80=20=EC=9E=88=EC=96=B4?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9C=ED=96=89=EC=99=84=EB=A3=8C=20=EB=90=98?= =?UTF-8?q?=EB=82=98=20=EC=B2=A8=EB=B6=80=ED=8C=8C=EC=9D=BC=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=98=A4=EB=A5=98=EB=A1=9C=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B4=EB=90=A8=20-=20=EC=A6=89=EC=8B=9C=EB=B0=9C?= =?UTF-8?q?=ED=96=89=20=ED=95=A8=EC=88=98=EC=97=90=20=EC=B2=A8=EB=B6=80?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?-=20=EC=A6=89=EC=8B=9C=EB=B0=9C=ED=96=89=EC=8B=9C=20=EC=B2=A8?= =?UTF-8?q?=EB=B6=80=ED=8C=8C=EC=9D=BC=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=EC=A0=80=EC=9E=A5->=EB=B0=9C=ED=96=89=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=EB=A1=9C=20=EC=B2=98=EB=A6=AC=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BO/Views/croom/taxdetail.cshtml | 28 ++++++------- Base/Controller/ACommonCRoom.cs | 48 ++++++++++++++++++----- Base/Popbill/PopbillService.cs | 69 ++++++++++++++++++--------------- 3 files changed, 91 insertions(+), 54 deletions(-) diff --git a/BO/Views/croom/taxdetail.cshtml b/BO/Views/croom/taxdetail.cshtml index 5033edd..20cbc50 100644 --- a/BO/Views/croom/taxdetail.cshtml +++ b/BO/Views/croom/taxdetail.cshtml @@ -253,7 +253,7 @@ } 발행취소 } - 목록 + 목록 @Html.Partial("./Partial/dform", Model) @@ -307,9 +307,9 @@ } function cbsave() { if (capResult.code == 1000) { - msg("저장되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); + msg("저장되었습니다.", null, null, null, null, "rfs(0,'sform');"); } else if (capResult.code == -1) { - msg("이미 발행요청건이 존재합니다."); + msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');"); } else { msgadmin(); } @@ -319,12 +319,12 @@ } function cbtempsave() { if (capResult.code == 1000) { - msg("임시저장되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); + msg("임시저장되었습니다.", null, null, null, null, "rfs(0,'sform');"); } else if (capResult.code == -1) { - msg("이미 발행요청건이 존재합니다."); + msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');"); } else { if (capResult.msg != "") { - msg(capResult.msg); + msg(capResult.msg, null, null, null, null, "rfs(0,'sform');"); } else { msgadmin(); } @@ -338,10 +338,10 @@ } function cbcancelIssue() { if (capResult.code == 1000) { - msg("발행취소되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); + msg("발행취소되었습니다.", null, null, null, null, "rfs(0,'sform');"); } else { if (capResult.msg != "") { - msg(capResult.msg); + msg(capResult.msg, null, null, null, null, "rfs(0,'sform');"); } else { msgadmin(); } @@ -354,12 +354,12 @@ } function cbIssue() { if (capResult.code == 1000) { - msg("발행되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); + msg("발행되었습니다.", null, null, null, null, "rfs(0,'sform');"); } else if (capResult.code == -1) { - msg("이미 발행요청건이 존재합니다."); + msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');"); } else { if (capResult.msg != "") { - msg(capResult.msg); + msg(capResult.msg, null, null, null, null, "rfs(0,'sform');"); } else { msgadmin(); } @@ -372,12 +372,12 @@ } function cbregistIssue() { if (capResult.code == 1000) { - msg("즉시발행되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); + msg("즉시발행되었습니다.", null, null, null, null, "rfs(0,'sform');"); } else if (capResult.code == -1) { - msg("이미 발행요청건이 존재합니다."); + msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');"); } else { if (capResult.msg != "") { - msg(capResult.msg); + msg(capResult.msg, null, null, null, null, "rfs(0,'sform');"); } else { msgadmin(); } diff --git a/Base/Controller/ACommonCRoom.cs b/Base/Controller/ACommonCRoom.cs index efb0874..b6e9a65 100644 --- a/Base/Controller/ACommonCRoom.cs +++ b/Base/Controller/ACommonCRoom.cs @@ -842,7 +842,7 @@ namespace NP.Base.Controllers payTax.udt = DateTime.Now; if (string.IsNullOrEmpty(payTax.mgtkey)) { - payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao, payTax.udt); + payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao, payTax.taxno, payTax.udt); } if (Dao.Save("cr.paytax.save", payTax) > 0) @@ -921,23 +921,46 @@ namespace NP.Base.Controllers payTax.udt = DateTime.Now; if (string.IsNullOrEmpty(payTax.mgtkey)) - { - payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao, payTax.udt); + { + payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao,payTax.taxno, payTax.udt); } if (Dao.Save("cr.paytax.save", payTax) > 0) { var payItems = Dao.Get("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", payTax.taxno } }); - - var result = Popbill.PopbillService.RegistIssue(Dao, payTax, payItems); - if (result.IsSuccess) + //첨부파일이 있으면 임시저장 후 발행처리 + if(payTax.fgno != null && payTax.fgno != 0) { - return JsonOK(result.Code); + var result = Popbill.PopbillService.TempSave(Dao, payTax, payItems); + if (result.IsSuccess) + { + var resultIssue = Popbill.PopbillService.Issue(payTax.mgtkey); + if (resultIssue.IsSuccess) + { + return JsonOK(resultIssue.Code); + } + else + { + return JsonError(JSONCode.Error, resultIssue.Message, resultIssue); + } + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } } else { - return JsonError(JSONCode.Error, result.Message, result); - } + var result = Popbill.PopbillService.RegistIssue(Dao, payTax, payItems); + if (result.IsSuccess) + { + return JsonOK(result.Code); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } } return JsonOK(0); } @@ -955,6 +978,13 @@ namespace NP.Base.Controllers payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); payTax.iscancel = 1; + //mgtkey 발급여부 체크 + var nowPayTax = Dao.Get("cr.paytaxes", new Hashtable() { { "taxno", payTax.taxno } }).FirstOrDefault(); + if (nowPayTax != null && !string.IsNullOrEmpty(nowPayTax.mgtkey)) + { + payTax.mgtkey = nowPayTax.mgtkey; + } + if (!string.IsNullOrEmpty(payTax.mgtkey)) { var taxinvoice = Popbill.PopbillService.GetTaxinvoice(payTax).Data; diff --git a/Base/Popbill/PopbillService.cs b/Base/Popbill/PopbillService.cs index 9028e75..5b1cbe5 100644 --- a/Base/Popbill/PopbillService.cs +++ b/Base/Popbill/PopbillService.cs @@ -19,40 +19,52 @@ namespace NP.Base.Popbill /// 세금계산서 mgtKey(문서번호) 생성 /// /// CommonDao + /// PayTax.taxno /// 발행일 /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// mgtKey - public static string MakeMgtKey(CommonDao Dao, DateTime writeDate, MgtKeyType keyType = MgtKeyType.SELL) + public static string MakeMgtKey(CommonDao Dao, long taxno, DateTime writeDate, MgtKeyType keyType = MgtKeyType.SELL) { int no = 1; - - var payTax = Dao.Get("cr.paytax.formgtkey", new Hashtable() { { "writeDate", writeDate } }).FirstOrDefault(); - if (payTax != null && !string.IsNullOrEmpty(payTax.mgtkey)) + string mgtkey = string.Empty; + var nowPayTax = Dao.Get("cr.paytaxes", new Hashtable() { { "taxno", taxno } }).FirstOrDefault(); + //이미 mgtkey 발급되어 있으면 발급된 mgtkey 사용 + if (nowPayTax != null && !string.IsNullOrEmpty(nowPayTax.mgtkey)) { - var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1); - - if (int.TryParse(strNo, out no)) + mgtkey = nowPayTax.mgtkey; + } + else + { + var payTax = Dao.Get("cr.paytax.formgtkey", new Hashtable() { { "writeDate", writeDate } }).FirstOrDefault(); + if (payTax != null && !string.IsNullOrEmpty(payTax.mgtkey)) { - ++no; + var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1); + + if (int.TryParse(strNo, out no)) + { + ++no; + } + } + + mgtkey = $"{writeDate:yyyy-MM-dd}-L{no:D5}"; + + bool isUse = true; + int checkLimit = 50; + while (isUse && checkLimit > 0) + { + isUse = PopbillConfig.taxinvoiceService.CheckMgtKeyInUse(PopbillConfig.CorpNum, keyType, mgtkey); + if (isUse) + { + ++no; + mgtkey = $"{writeDate:yyyy-MM-dd}-L{no:D5}"; + } + else + { + break; + } + --checkLimit; } } - - string mgtkey = $"{writeDate:yyyy-MM-dd}-L{no:D5}"; - - bool isUse = true; - int checkLimit = 50; - while (isUse && checkLimit > 0) - { - isUse = PopbillConfig.taxinvoiceService.CheckMgtKeyInUse(PopbillConfig.CorpNum, keyType, mgtkey); - if (isUse) - { - ++no; - mgtkey = $"{writeDate:yyyy-MM-dd}-L{no:D5}"; - } - - --checkLimit; - } - return mgtkey; } #endregion @@ -401,12 +413,7 @@ namespace NP.Base.Popbill 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); - } + result.Message = result.Data.message; } catch (PopbillException ex) {