diff --git a/BO/Controllers/croomController.cs b/BO/Controllers/croomController.cs index f4fecc0..a7759f7 100644 --- a/BO/Controllers/croomController.cs +++ b/BO/Controllers/croomController.cs @@ -795,17 +795,15 @@ namespace NP.BO.Controllers vm.PayTaxItem = Dao.Get("cr.paytaxitem2", new System.Collections.Hashtable() { { "taxno", vm.longval } }); #region 세금계산서 Popbill 연동 - var mgtkey = vm.PayTaxes.First()?.mgtkey; - if (!string.IsNullOrEmpty(mgtkey)) + var payTax = vm.PayTaxes.First(); + if (payTax != null) { - ViewBag.Taxinvoice = PopbillService.GetTaxinvoice(mgtkey).Data; + var result = PopbillService.GetTaxinvoice(payTax); + if (result.IsSuccess) + { + ViewBag.Taxinvoice = result.Data; + } } - else - { - var taxdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); - mgtkey = PopbillService.MakeMgtKey(Dao, taxdate, MgtKeyType.SELL).Data; - ViewBag.Taxinvoice = PopbillService.GetTaxinvoiceR(mgtkey).Data; - } #endregion return View(vm); diff --git a/BO/Views/croom/taxdetail.cshtml b/BO/Views/croom/taxdetail.cshtml index ef3c86e..c829057 100644 --- a/BO/Views/croom/taxdetail.cshtml +++ b/BO/Views/croom/taxdetail.cshtml @@ -109,33 +109,33 @@ 회사명 - + 대표자 - + 사업자등록번호 - + 업태 - + 종목 - + 사업장주소 - + 담당자 - + 연락처 - + 이메일주소 - + 문서번호 - + @@ -175,8 +175,6 @@ 발행일 - - @@ -196,7 +194,10 @@ 영수구분 - @(t.isreceipt == 0 ? "청구" : "영수") + + + + 기재사항 @@ -209,26 +210,35 @@ + +
- 저장 - @if (string.IsNullOrEmpty(t.mgtkey)) + @if (t.iscancel == null || t.iscancel.Value != 1) { - 임시저장 및 미리보기 - 계산서 즉시발행 - } - else - { - if (string.IsNullOrEmpty(taxinvoice.ntsconfirmNum)) + + if (string.IsNullOrEmpty(t.mgtkey)) { - 임시저장 및 미리보기 + 저장 + 임시저장 계산서 즉시발행 + 발행취소 } else { - 계산서조회 + if (string.IsNullOrEmpty(taxinvoice.ntsconfirmNum)) + { + 저장 + 임시저장 + 미리보기 + 계산서 즉시발행 + 발행취소 + } + else + { + 계산서조회 + } } } - 발행취소 목록
@Html.Partial("./Partial/dform", Model) @@ -273,17 +283,12 @@ @section scripts{ -} - +} \ No newline at end of file diff --git a/Base/Controller/ACommonCRoom.cs b/Base/Controller/ACommonCRoom.cs index 29719fc..1608990 100644 --- a/Base/Controller/ACommonCRoom.cs +++ b/Base/Controller/ACommonCRoom.cs @@ -773,66 +773,193 @@ namespace NP.Base.Controllers } return JsonOK(Dao.Save("cr.paytax.save", d)); } + + #region 세금계산서 임시저장(팝빌 임시저장 및 paytax.mgtkey 업데이트) /// - /// 팝빌 임시저장 및 미리보기(팝빌 임시저장 및 paytax.mgtkey 업데이트 후 세금계산서 인쇄 url 리턴) + /// 세금계산서 임시저장(팝빌 임시저장 및 paytax.mgtkey 업데이트) /// - /// + /// payTax /// [HttpPost] - public JsonResult PayTaxRegister(PayTax d) + public JsonResult PayTaxTempSave(PayTax payTax) { - d.uno = SUserInfo.UserNo; d.uip = GetUserIP(); - if (d.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", d.payno }, { "cno", d.cno }, { "iscancel", 0 }, { "nottaxno", d.taxno } }).Count() > 0) + payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); + if (payTax.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", payTax.payno }, { "cno", payTax.cno }, { "iscancel", 0 }, { "nottaxno", payTax.taxno } }).Count() > 0) { return JsonBack(new JsonRtn() { code = -1 }); } - return JsonOK(Dao.Save("cr.paytax.save", d)); + + payTax.udt = DateTime.Now; + if (string.IsNullOrEmpty(payTax.mgtkey)) + { + payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao, 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.TempSave(payTax, payItems); + if (result.IsSuccess) + { + return JsonOK(result.Code); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } + return JsonOK(0); } + #endregion + + #region 세금계산서 발행(팝빌 발행 및 paytax.taxdate 업데이트) /// - /// 계산서 즉시발행(팝빌 발행 및 paytax.taxdate ,paytax.mgtkey 업데이트) + /// 세금계산서 발행(팝빌 발행 및 paytax.taxdate 업데이트) /// - /// + /// /// [HttpPost] - public JsonResult PayTaxRegistIssue(PayTax d) + public JsonResult PayTaxIssue(PayTax payTax) { - d.uno = SUserInfo.UserNo; d.uip = GetUserIP(); - if (d.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", d.payno }, { "cno", d.cno }, { "iscancel", 0 }, { "nottaxno", d.taxno } }).Count() > 0) + payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); + if (payTax.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", payTax.payno }, { "cno", payTax.cno }, { "iscancel", 0 }, { "nottaxno", payTax.taxno } }).Count() > 0) { return JsonBack(new JsonRtn() { code = -1 }); } - return JsonOK(Dao.Save("cr.paytax.save", d)); + + if (payTax.taxdate == null) + { + payTax.taxdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + } + + if (Dao.Save("cr.paytax.save", payTax) > 0) + { + var result = Popbill.PopbillService.Issue(payTax.mgtkey); + if (result.IsSuccess) + { + return JsonOK(result.Code); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } + return JsonOK(0); } + #endregion + + #region 세금계산서 즉시발행(팝빌 발행 및 paytax.taxdate ,paytax.mgtkey 업데이트) /// - /// 발행취소(발행전: paytax.iscancel 상태값 변경, 발행완료: 팝빌 발행취소 및 paytax.iscancel 상태값 변경) + /// 세금계산서 즉시발행(팝빌 발행 및 paytax.taxdate ,paytax.mgtkey 업데이트) /// - /// + /// payTax /// [HttpPost] - public JsonResult PayTaxCancelIssue(PayTax d) + public JsonResult PayTaxRegistIssue(PayTax payTax) { - d.uno = SUserInfo.UserNo; d.uip = GetUserIP(); - if (d.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", d.payno }, { "cno", d.cno }, { "iscancel", 0 }, { "nottaxno", d.taxno } }).Count() > 0) + payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); + if (payTax.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", payTax.payno }, { "cno", payTax.cno }, { "iscancel", 0 }, { "nottaxno", payTax.taxno } }).Count() > 0) { return JsonBack(new JsonRtn() { code = -1 }); } - return JsonOK(Dao.Save("cr.paytax.save", d)); + + if (payTax.taxdate == null) + { + payTax.taxdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + } + + payTax.udt = DateTime.Now; + if (string.IsNullOrEmpty(payTax.mgtkey)) + { + payTax.mgtkey = Popbill.PopbillService.MakeMgtKey(Dao, 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(payTax, payItems); + if (result.IsSuccess) + { + return JsonOK(result.Code); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } + return JsonOK(0); } + #endregion + + #region 세금계산서 발행취소(발행전: paytax.iscancel 상태값 변경, 발행완료: 팝빌 발행취소 및 paytax.iscancel 상태값 변경) /// - /// 계산서조회(팝빌 세금계산서 인쇄 url 리턴) + /// 세금계산서 발행취소(발행전: paytax.iscancel 상태값 변경, 발행완료: 팝빌 발행취소 및 paytax.iscancel 상태값 변경) /// - /// + /// /// [HttpPost] - public JsonResult PayTaxView(PayTax d) + public JsonResult PayTaxCancelIssue(PayTax payTax) { - d.uno = SUserInfo.UserNo; d.uip = GetUserIP(); - if (d.iscancel != 1 && Dao.Get("cr.paytaxes", new Hashtable() { { "payno", d.payno }, { "cno", d.cno }, { "iscancel", 0 }, { "nottaxno", d.taxno } }).Count() > 0) + payTax.uno = SUserInfo.UserNo; payTax.uip = GetUserIP(); + payTax.iscancel = 1; + + if (!string.IsNullOrEmpty(payTax.mgtkey)) { - return JsonBack(new JsonRtn() { code = -1 }); + 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) + { + return JsonOK(result.Code); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } + else + { + return JsonOK(0); + } + } + else + { + return JsonOK(Dao.Save("cr.paytax.save", payTax)); + } + } + else + { + return JsonOK(Dao.Save("cr.paytax.save", payTax)); } - return JsonOK(Dao.Save("cr.paytax.save", d)); } + #endregion + + #region 세금계산서 조회(팝빌 세금계산서 인쇄 url 리턴) + /// + /// 세금계산서 조회(팝빌 세금계산서 인쇄 url 리턴) + /// + /// + /// + [HttpPost] + public JsonResult PayTaxView(PayTax payTax) + { + var result = Popbill.PopbillService.GetPrintURL(payTax.mgtkey); + if (result.IsSuccess) + { + return JsonObj(result.Data); + } + else + { + return JsonError(JSONCode.Error, result.Message, result); + } + } + #endregion + [HttpPost] public JsonResult SmartTaxView(String csid) { diff --git a/Base/Popbill/PopbillConfig.cs b/Base/Popbill/PopbillConfig.cs index d5e17c3..ca461e0 100644 --- a/Base/Popbill/PopbillConfig.cs +++ b/Base/Popbill/PopbillConfig.cs @@ -56,7 +56,7 @@ namespace NP.Base.Popbill _linkID = WebConfigurationManager.AppSettings["Popbill.LinkID"]; _secretKey = WebConfigurationManager.AppSettings["Popbill.SecretKey"]; _corpNum = WebConfigurationManager.AppSettings["Popbill.CorpNum"]; - _userID = WebConfigurationManager.AppSettings["Popbill.UserID"]; + _userID = WebConfigurationManager.AppSettings["Popbill.UserID"] != string.Empty ? WebConfigurationManager.AppSettings["Popbill.UserID"] : null ; // 세금계산서 서비스 객체 초기화 taxinvoiceService = new TaxinvoiceService(_linkID, _secretKey); diff --git a/Base/Popbill/PopbillService.cs b/Base/Popbill/PopbillService.cs index cbf5c34..ab3c326 100644 --- a/Base/Popbill/PopbillService.cs +++ b/Base/Popbill/PopbillService.cs @@ -13,272 +13,375 @@ namespace NP.Base.Popbill { public class PopbillService { + #region 세금계산서 mgtKey(문서번호) 생성 /// - /// 세금계산서 문서번호{mgtKey} 생성 + /// 세금계산서 mgtKey(문서번호) 생성 /// /// CommonDao - /// 발행일 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// 발행일 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// mgtKey - public static Result MakeMgtKey(CommonDao Dao, DateTime taxdate, MgtKeyType mgtKeyType = MgtKeyType.SELL) - { - Result result = new Result(); + public static string MakeMgtKey(CommonDao Dao, 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)) + { + var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1); + + if (int.TryParse(strNo, out no)) + { + ++no; + } + } + + 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; + } - try - { - string mgtkey = string.Empty; - int no = 1; - - var payTax = Dao.Get("cr.paytax.formgtkey", new Hashtable() { { "taxdate", taxdate } }).FirstOrDefault(); - if (payTax == null) - { - payTax = new PayTax() { }; - } - if (payTax.taxdate == null) - { - payTax.taxdate = taxdate; - } - - if (!string.IsNullOrEmpty(payTax.mgtkey)) - { - var strNo = payTax.mgtkey.Substring(payTax.mgtkey.IndexOf("L") + 1); - - if (int.TryParse(strNo, out no)) - { - ++no; - } - } - - mgtkey = $"{taxdate:yyyy-MM-dd}-L{no:D5}"; - - bool isUse = true; - int checkLimit = 10; - while (isUse && checkLimit > 0) - { - isUse = PopbillConfig.taxinvoiceService.CheckMgtKeyInUse(PopbillConfig.CorpNum, mgtKeyType, mgtkey); - if (isUse) - { - ++no; - mgtkey = $"{taxdate:yyyy-MM-dd}-L{no:D5}"; - } - - --checkLimit; - } - result.Data = mgtkey; - } - catch (PopbillException ex) - { - result.Code = ex.code.ToString(); - result.Message = ex.Message; - Logger.TryError(ex.Message, ex); - } - return result; + return mgtkey; } + #endregion + #region 세금계산서 Taxinvoice 생성 + /// + /// 세금계산서 Taxinvoice 생성 + /// + /// Taxinvoice + /// PayTax + /// payItems + /// Taxinvoice + public static Taxinvoice MakeTaxinvoice(Taxinvoice taxinvoice, PayTax payTax, IList payItems) + { + taxinvoice.issueType = "정발행"; //"정발행" / "역발행" / "위수탁" 중 택 1 + taxinvoice.taxType = "면세"; //"과세" / "영세" / "면세" 중 택 1 + taxinvoice.chargeDirection = "정과금"; //"정과금" / "역과금" 중 택 1 + taxinvoice.writeDate = payTax.udt.ToString("yyyyMMdd"); + taxinvoice.purposeType = payTax.isreceipt == 0 ? "청구" : "영수"; //0:청구, 1:영수 {"영수" / "청구" / "없음" 중 택 1} + taxinvoice.supplyCostTotal = payTax.taxamt.ToString(); + taxinvoice.taxTotal = "0"; + taxinvoice.totalAmount = payTax.taxamt.ToString(); + taxinvoice.invoiceeType = "사업자"; + taxinvoice.invoiceeCorpNum = payTax.brno; + taxinvoice.invoiceeCorpName = payTax.asname; + taxinvoice.invoiceeCEOName = payTax.ceoname; + taxinvoice.invoiceeAddr = payTax.asaddr; + taxinvoice.invoiceeBizType = payTax.btype; + taxinvoice.invoiceeBizClass = payTax.bkind; + taxinvoice.invoiceeContactName1 = payTax.manname; + taxinvoice.invoiceeTEL1 = payTax.telno; + taxinvoice.invoiceeEmail1 = payTax.email; + //taxinvoice.serialNum = payTax.taxno.ToString(); + + #region 상세항목(품목) 정보 + if (payItems != null) + { + /************************************************************************** + * 상세항목(품목) 정보 * + * - 상세항목 정보는 세금계산서 필수기재사항이 아니므로 작성하지 않더라도 * + * 세금계산서 발행이 가능합니다. * + * - 최대 99건까지 작성가능 * + **************************************************************************/ + + taxinvoice.detailList = new List(); + var serialNum = 1; + foreach (var payItem in payItems) + { + TaxinvoiceDetail detail = new TaxinvoiceDetail(); + detail.serialNum = serialNum; // 일련번호, 1부터 순차기재 + detail.purchaseDT = payItem.payoktime.Value.ToString("yyyyMMdd"); // 거래일자 + detail.itemName = payItem.itemname; // 품목명 + detail.spec = ""; // 규격 + detail.qty = payItem.pcnt.ToString(); // 수량 + detail.unitCost = payItem.payamt.ToString(); // 단가 + detail.supplyCost = payItem.payamt.ToString(); // 공급가액 + detail.tax = "0"; // 세액 + detail.remark = ""; // 비고 + taxinvoice.detailList.Add(detail); + ++serialNum; + } + } + #endregion + + return taxinvoice; + } + #endregion + + #region 세금계산서 상세정보 /// /// 세금계산서 상세정보 /// - /// 파트너가 할당한 문서번호 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// PayTax + /// payItems + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// Taxinvoice - public static Result GetTaxinvoice(string mgtkey, MgtKeyType mgtKeyType = MgtKeyType.SELL) - { - Result result = new Result(); - try - { - result.Data = PopbillConfig.taxinvoiceService.GetDetailInfo(PopbillConfig.CorpNum, mgtKeyType, mgtkey); - } - catch (PopbillException ex) - { - result.Code = ex.code.ToString(); - result.Message = ex.Message; - Logger.TryError(ex.Message, ex); - } - finally - { - if (result.Data == null) - { - result.Data = new Taxinvoice() { invoicerMgtKey = mgtkey }; - } - } - return result; - } - - /// - /// 세금계산서 공급자정보 - /// - /// 파트너가 할당한 문서번호 - /// Taxinvoice - public static Result GetTaxinvoiceR(string mgtkey) - { - Result result = new Result(); - try - { - CorpInfo corpInfo = PopbillConfig.taxinvoiceService.GetCorpInfo(PopbillConfig.CorpNum, PopbillConfig.UserID); - Contact contact = PopbillConfig.taxinvoiceService.ListContact(PopbillConfig.CorpNum, PopbillConfig.UserID).Where(w => w.mgrYN == true).FirstOrDefault(); - result.Data = new Taxinvoice - { - invoicerAddr = corpInfo?.addr, - invoicerCEOName = corpInfo?.ceoname, - invoicerCorpName = corpInfo?.corpName, - invoicerMgtKey = mgtkey, - invoicerCorpNum = PopbillConfig.CorpNum, - invoicerBizClass = corpInfo?.bizClass, - invoicerBizType = corpInfo?.bizType, - invoicerContactName = contact?.personName, - invoicerEmail = contact?.email, - invoicerHP = contact?.hp, - invoicerTEL = contact?.tel - }; - } - catch (PopbillException ex) - { - result.Code = ex.code.ToString(); - result.Message = ex.Message; - Logger.TryError(ex.Message, ex); - } - return result; - } - - /// - /// 세금계산서 임시저장 - /// - /// Taxinvoice - /// IssueResponse - public static Result Register(Taxinvoice taxinvoice) + public static Result GetTaxinvoice(PayTax payTax, IList payItems = null, MgtKeyType keyType = MgtKeyType.SELL) { - Result result = new Result(); + Result result = new Result(); try { - result.Data = PopbillConfig.taxinvoiceService.Register(PopbillConfig.CorpNum, taxinvoice); + if (!string.IsNullOrEmpty(payTax.mgtkey) && PopbillConfig.taxinvoiceService.CheckMgtKeyInUse(PopbillConfig.CorpNum, keyType, payTax.mgtkey)) + { + result.Data = PopbillConfig.taxinvoiceService.GetDetailInfo(PopbillConfig.CorpNum, keyType, payTax.mgtkey); + } + else + { + CorpInfo corpInfo = PopbillConfig.taxinvoiceService.GetCorpInfo(PopbillConfig.CorpNum, PopbillConfig.UserID); + Contact contact = PopbillConfig.taxinvoiceService.ListContact(PopbillConfig.CorpNum, PopbillConfig.UserID).Where(w => w.mgrYN == true).FirstOrDefault(); + result.Data = new Taxinvoice + { + invoicerAddr = corpInfo?.addr, + invoicerCEOName = corpInfo?.ceoname, + invoicerCorpName = corpInfo?.corpName, + invoicerMgtKey = payTax.mgtkey, + invoicerCorpNum = PopbillConfig.CorpNum, + invoicerBizClass = corpInfo?.bizClass, + invoicerBizType = corpInfo?.bizType, + invoicerContactName = contact?.personName, + invoicerEmail = contact?.email, + invoicerHP = contact?.hp, + invoicerTEL = contact?.tel + }; + } + result.Data = MakeTaxinvoice(result.Data, payTax, payItems); } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; } + #endregion + #region 세금계산서 임시저장(수정) + /// + /// 세금계산서 임시저장(수정) + /// + /// payTax + /// payItems + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// mgtkey + /// 작성된 세금계산서 데이터를 팝빌에 저장합니다. + public static Result TempSave(PayTax payTax, IList payItems, MgtKeyType keyType = MgtKeyType.SELL) + { + Result result = new Result(); + 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); + } + else + { + response = PopbillConfig.taxinvoiceService.Register(PopbillConfig.CorpNum, taxinvoice); + } + result.Data = payTax.mgtkey; + result.Code = response.code; + result.Message = response.message; + } + catch (PopbillException ex) + { + result.IsSuccess = false; + result.Code = ex.code; + result.Message = ex.Message; + Logger.TryError(ex.Message, ex); + } + return result; + } + #endregion + + #region 세금계산서 발행 /// /// 세금계산서 발행 /// /// 파트너가 할당한 문서번호 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// 지연발행 가능여부 /// 메모 /// IssueResponse - public static Result Issue(string mgtkey, MgtKeyType mgtKeyType = MgtKeyType.SELL, string memo = "") + /// "임시저장" 또는 "(역)발행대기" 상태의 세금계산서를 발행(전자서명)하며, "발행완료" 상태로 처리합니다 + public static Result Issue(string mgtkey, MgtKeyType keyType = MgtKeyType.SELL, bool forceIssue = false, string memo = "") { Result result = new Result(); try { - result.Data = PopbillConfig.taxinvoiceService.Issue(PopbillConfig.CorpNum, mgtKeyType, mgtkey, memo, PopbillConfig.UserID); + result.Data = PopbillConfig.taxinvoiceService.Issue(PopbillConfig.CorpNum, keyType, mgtkey, memo, forceIssue, PopbillConfig.UserID); + result.Code = result.Data.code; + result.Message = result.Data.message; } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; } + #endregion + #region 세금계산서 발행취소 /// /// 세금계산서 발행취소 /// /// 파트너가 할당한 문서번호 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// 메모 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// IssueResponse - public static Result CancelIssue(string mgtkey, MgtKeyType mgtKeyType = MgtKeyType.SELL, string memo = "") + /// 국세청 전송 이전 "발행완료" 상태의 전자세금계산서를 "발행취소"하고, 해당 건은 국세청 신고 대상에서 제외됩니다. + public static Result CancelIssue(string mgtkey, string memo = "", MgtKeyType keyType = MgtKeyType.SELL) { Result result = new Result(); try { - result.Data = PopbillConfig.taxinvoiceService.CancelIssue(PopbillConfig.CorpNum, mgtKeyType, mgtkey, memo, PopbillConfig.UserID); + result.Data = PopbillConfig.taxinvoiceService.CancelIssue(PopbillConfig.CorpNum, keyType, mgtkey, memo, PopbillConfig.UserID); + result.Code = result.Data.code; + result.Message = result.Data.message; } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; } + #endregion + #region 세금계산서 삭제 + /// + /// 세금계산서 삭제 (국세청으로 전송되지 않은 세금계산서를 삭제합니다.) + /// + /// 파트너가 할당한 문서번호 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// IssueResponse + /// 국세청으로 전송되지 않은 세금계산서를 삭제합니다. + public static Result Delete(string mgtkey, MgtKeyType keyType = MgtKeyType.SELL) + { + Result result = new Result(); + 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 세금계산서 즉시 발행 /// /// 세금계산서 즉시 발행 /// - /// Taxinvoice + /// payTax + /// payItems /// 지연발행 가능여부 /// 메모 /// IssueResponse - public static Result RegistIssue(Taxinvoice taxinvoice, bool forceIssue = false, string memo = "") + /// 작성된 세금계산서 데이터를 팝빌에 저장과 동시에 발행(전자서명)하여 "발행완료" 상태로 처리합니다. + public static Result RegistIssue(PayTax payTax, IList payItems, bool forceIssue = false, string memo = "") { - Result result = new Result();; + Result result = new Result(); ; try { + var taxinvoice = GetTaxinvoice(payTax, payItems).Data; result.Data = PopbillConfig.taxinvoiceService.RegistIssue(PopbillConfig.CorpNum, taxinvoice, forceIssue, memo); + result.Code = result.Data.code; + result.Message = result.Data.message; } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; - } + } + #endregion + #region 세금계산서 인쇄 팝업 URL 확인 /// /// 세금계산서 인쇄 팝업 URL 확인 /// /// 파트너가 할당한 문서번호 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// URL - public static Result GetPrintURL(string mgtkey, MgtKeyType mgtKeyType = MgtKeyType.SELL) + public static Result GetPrintURL(string mgtkey, MgtKeyType keyType = MgtKeyType.SELL) { Result result = new Result(); ; try { - result.Data = PopbillConfig.taxinvoiceService.GetPrintURL(PopbillConfig.CorpNum, mgtKeyType, mgtkey, PopbillConfig.UserID); + result.Data = PopbillConfig.taxinvoiceService.GetPrintURL(PopbillConfig.CorpNum, keyType, mgtkey, PopbillConfig.UserID); } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; - } + } + #endregion + #region 세금계산서 인쇄 팝업 URL 확인 - 공급받는자용 /// /// 세금계산서 인쇄 팝업 URL 확인 - 공급받는자용 /// /// 파트너가 할당한 문서번호 - /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 + /// 세금계산서 유형 : SELL = 매출, BUY = 매입, TRUSTEE = 위수탁 /// URL - public static Result GetEPrintURL(string mgtkey, MgtKeyType mgtKeyType = MgtKeyType.SELL) + public static Result GetEPrintURL(string mgtkey, MgtKeyType keyType = MgtKeyType.SELL) { Result result = new Result(); ; try { - result.Data = PopbillConfig.taxinvoiceService.GetEPrintURL(PopbillConfig.CorpNum, mgtKeyType, mgtkey, PopbillConfig.UserID); + result.Data = PopbillConfig.taxinvoiceService.GetEPrintURL(PopbillConfig.CorpNum, keyType, mgtkey, PopbillConfig.UserID); } catch (PopbillException ex) { - result.Code = ex.code.ToString(); + result.IsSuccess = false; + result.Code = ex.code; result.Message = ex.Message; Logger.TryError(ex.Message, ex); } return result; - } + } + #endregion } public class Result { - public String Code = null; - public String Message = null; + public bool IsSuccess = true; + public long Code = 1; + public String Message = string.Empty; public T Data; } -} \ No newline at end of file +} diff --git a/Dao/MyBatis/Maps/CRoom.xml b/Dao/MyBatis/Maps/CRoom.xml index c12bdab..209e208 100644 --- a/Dao/MyBatis/Maps/CRoom.xml +++ b/Dao/MyBatis/Maps/CRoom.xml @@ -1311,9 +1311,9 @@ where a.payno=#payno#