오류수정 : 계산서 즉시발행시 첨부파일이 있으면 발행 후 수정이 안되는 오류가 있어서 발행완료 되나 첨부파일등록 오류로 에러 리턴됨

- 즉시발행 함수에 첨부파일 로직 삭제
- 즉시발행시 첨부파일 있으면 임시저장->발행 순서로 처리하게 로직 수정
This commit is contained in:
lch 2021-07-05 05:15:14 +00:00
parent 5066977cb6
commit fa2df36c09
3 changed files with 91 additions and 54 deletions

View File

@ -253,7 +253,7 @@
} }
<a href="#" class="btn btn-danger" onclick="cancelIssue();">발행취소</a> <a href="#" class="btn btn-danger" onclick="cancelIssue();">발행취소</a>
} }
<a href="#" class="btn btn-default" onclick="$('#dform').attr('action', '/croom/tax');golist();">목록</a> <a href="#" class="btn btn-default" onclick="golist();">목록</a>
</div> </div>
@Html.Partial("./Partial/dform", Model) @Html.Partial("./Partial/dform", Model)
</form> </form>
@ -307,9 +307,9 @@
} }
function cbsave() { function cbsave() {
if (capResult.code == 1000) { 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) { } else if (capResult.code == -1) {
msg("이미 발행요청건이 존재합니다."); msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');");
} else { } else {
msgadmin(); msgadmin();
} }
@ -319,12 +319,12 @@
} }
function cbtempsave() { function cbtempsave() {
if (capResult.code == 1000) { 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) { } else if (capResult.code == -1) {
msg("이미 발행요청건이 존재합니다."); msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');");
} else { } else {
if (capResult.msg != "") { if (capResult.msg != "") {
msg(capResult.msg); msg(capResult.msg, null, null, null, null, "rfs(0,'sform');");
} else { } else {
msgadmin(); msgadmin();
} }
@ -338,10 +338,10 @@
} }
function cbcancelIssue() { function cbcancelIssue() {
if (capResult.code == 1000) { if (capResult.code == 1000) {
msg("발행취소되었습니다.", null, null, null, null, "bglayer();rfs(0,'sform');"); msg("발행취소되었습니다.", null, null, null, null, "rfs(0,'sform');");
} else { } else {
if (capResult.msg != "") { if (capResult.msg != "") {
msg(capResult.msg); msg(capResult.msg, null, null, null, null, "rfs(0,'sform');");
} else { } else {
msgadmin(); msgadmin();
} }
@ -354,12 +354,12 @@
} }
function cbIssue() { function cbIssue() {
if (capResult.code == 1000) { 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) { } else if (capResult.code == -1) {
msg("이미 발행요청건이 존재합니다."); msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');");
} else { } else {
if (capResult.msg != "") { if (capResult.msg != "") {
msg(capResult.msg); msg(capResult.msg, null, null, null, null, "rfs(0,'sform');");
} else { } else {
msgadmin(); msgadmin();
} }
@ -372,12 +372,12 @@
} }
function cbregistIssue() { function cbregistIssue() {
if (capResult.code == 1000) { 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) { } else if (capResult.code == -1) {
msg("이미 발행요청건이 존재합니다."); msg("이미 발행요청건이 존재합니다.", null, null, null, null, "rfs(0,'sform');");
} else { } else {
if (capResult.msg != "") { if (capResult.msg != "") {
msg(capResult.msg); msg(capResult.msg, null, null, null, null, "rfs(0,'sform');");
} else { } else {
msgadmin(); msgadmin();
} }

View File

@ -842,7 +842,7 @@ namespace NP.Base.Controllers
payTax.udt = DateTime.Now; payTax.udt = DateTime.Now;
if (string.IsNullOrEmpty(payTax.mgtkey)) 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) if (Dao.Save("cr.paytax.save", payTax) > 0)
@ -922,21 +922,44 @@ namespace NP.Base.Controllers
payTax.udt = DateTime.Now; payTax.udt = DateTime.Now;
if (string.IsNullOrEmpty(payTax.mgtkey)) 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) if (Dao.Save("cr.paytax.save", payTax) > 0)
{ {
var payItems = Dao.Get<PayItem>("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", payTax.taxno } }); var payItems = Dao.Get<PayItem>("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", payTax.taxno } });
//첨부파일이 있으면 임시저장 후 발행처리
var result = Popbill.PopbillService.RegistIssue(Dao, payTax, payItems); if(payTax.fgno != null && payTax.fgno != 0)
if (result.IsSuccess)
{ {
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 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); return JsonOK(0);
@ -955,6 +978,13 @@ namespace NP.Base.Controllers
payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP();
payTax.iscancel = 1; payTax.iscancel = 1;
//mgtkey 발급여부 체크
var nowPayTax = Dao.Get<PayTax>("cr.paytaxes", new Hashtable() { { "taxno", payTax.taxno } }).FirstOrDefault();
if (nowPayTax != null && !string.IsNullOrEmpty(nowPayTax.mgtkey))
{
payTax.mgtkey = nowPayTax.mgtkey;
}
if (!string.IsNullOrEmpty(payTax.mgtkey)) if (!string.IsNullOrEmpty(payTax.mgtkey))
{ {
var taxinvoice = Popbill.PopbillService.GetTaxinvoice(payTax).Data; var taxinvoice = Popbill.PopbillService.GetTaxinvoice(payTax).Data;

View File

@ -19,40 +19,52 @@ namespace NP.Base.Popbill
/// 세금계산서 mgtKey(문서번호) 생성 /// 세금계산서 mgtKey(문서번호) 생성
/// </summary> /// </summary>
/// <param name="Dao">CommonDao</param> /// <param name="Dao">CommonDao</param>
/// <param name="taxno">PayTax.taxno</param>
/// <param name="writeDate">발행일</param> /// <param name="writeDate">발행일</param>
/// <param name="keyType">세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁</param> /// <param name="keyType">세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁</param>
/// <returns>mgtKey</returns> /// <returns>mgtKey</returns>
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; int no = 1;
string mgtkey = string.Empty;
var payTax = Dao.Get<PayTax>("cr.paytax.formgtkey", new Hashtable() { { "writeDate", writeDate } }).FirstOrDefault(); var nowPayTax = Dao.Get<PayTax>("cr.paytaxes", new Hashtable() { { "taxno", taxno } }).FirstOrDefault();
if (payTax != null && !string.IsNullOrEmpty(payTax.mgtkey)) //이미 mgtkey 발급되어 있으면 발급된 mgtkey 사용
if (nowPayTax != null && !string.IsNullOrEmpty(nowPayTax.mgtkey))
{ {
var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1); mgtkey = nowPayTax.mgtkey;
if (int.TryParse(strNo, out no))
{
++no;
}
} }
else
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); var payTax = Dao.Get<PayTax>("cr.paytax.formgtkey", new Hashtable() { { "writeDate", writeDate } }).FirstOrDefault();
if (isUse) if (payTax != null && !string.IsNullOrEmpty(payTax.mgtkey))
{ {
++no; var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1);
mgtkey = $"{writeDate:yyyy-MM-dd}-L{no:D5}";
if (int.TryParse(strNo, out no))
{
++no;
}
} }
--checkLimit; 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;
}
}
return mgtkey; return mgtkey;
} }
#endregion #endregion
@ -402,11 +414,6 @@ namespace NP.Base.Popbill
result.Data = PopbillConfig.taxinvoiceService.RegistIssue(PopbillConfig.CorpNum, taxinvoice, forceIssue, memo); result.Data = PopbillConfig.taxinvoiceService.RegistIssue(PopbillConfig.CorpNum, taxinvoice, forceIssue, memo);
result.Code = result.Data.code; result.Code = result.Data.code;
result.Message = result.Data.message; result.Message = result.Data.message;
if (result.Data.code == 1)
{
AttachFile(Dao, payTax, keyType);
}
} }
catch (PopbillException ex) catch (PopbillException ex)
{ {