/// <summary> /// Retrieve receipt information of specific receipt no. /// </summary> /// <param name="param">receipt no.</param> /// <returns></returns> public ActionResult ICS060_GetReceipt(ICS060_ScreenParameter param) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; doReceipt doReceipt; try { //Validate receipt business doReceipt = ICS060_ValidateReceiptBusiness(param, res); if (res.IsError || doReceipt == null) { return(Json(res)); } //Pass, Set doReceipt ICS060_ReceiptInformation result = new ICS060_ReceiptInformation(); result.doReceipt = doReceipt; //Set cancel method IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler; // Add By Sommai P., Oct 31, 2013 bool isIssuedTaxInvoice = billingHandler.CheckInvoiceIssuedTaxInvoice(doReceipt.InvoiceNo, doReceipt.InvoiceOCC); bool isCancelTaxInvoiceOption = incomeHandler.CheckCancelTaxInvoiceOption(doReceipt.InvoiceNo, doReceipt.InvoiceOCC); // Add By Sommai P., Oct 31, 2013 string filterValueCode = "%"; if (isIssuedTaxInvoice == false || isCancelTaxInvoiceOption == false) // Modify By Sommai P., Oct 31, 2013 { filterValueCode = CancelReceiptTarget.C_CANCEL_RECEIPT_ONLY; } ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> miscs = new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CANCEL_RECEIPT_TARGET, ValueCode = filterValueCode } }; ICommonHandler hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> lst = hand.GetMiscTypeCodeList(miscs); ComboBoxModel cboModel = new ComboBoxModel(); cboModel.SetList <doMiscTypeCode>(lst, "ValueDisplay", "ValueCode"); result.CancelMethodComboBoxModel = cboModel; res.ResultData = result; return(Json(res)); } catch (Exception ex) { res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Event when click confirm cancel button, this function will cancel the issued receipt information of specific receipt no. to the system. /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult ICS060_cmdConfirmCancel(ICS060_ScreenParameter param) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; doReceipt doReceipt; try { if (IsSuspend(res)) { return(Json(res)); } if (!ICS060_IsAllowOperate(res)) { return(Json(res)); } //Validate receipt business doReceipt = ICS060_ValidateReceiptBusiness(param, res); if (res.IsError || doReceipt == null) { return(Json(res)); } //Connect db using (TransactionScope scope = new TransactionScope()) { try { //Cancel receipt IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler; bool isSuccess = incomeHandler.CancelReceipt(doReceipt); if (!isSuccess) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null); } IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; //Get Invoice doInvoice doInvoice = billingHandler.GetInvoice(doReceipt.InvoiceNo); if (doInvoice == null) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null); } //string invoiceType = billingHandler.GetInvoiceType(doInvoice.BillingTypeCode); //if ((invoiceType == InvoiceType.C_INVOICE_TYPE_DEPOSIT || invoiceType == InvoiceType.C_INVOICE_TYPE_SERVICE) // && (doInvoice.IssueReceiptTiming != IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV // || (doInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV // && doInvoice.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_MESSENGER_TRANSFER))) bool isIssuedTaxInvoice = billingHandler.CheckInvoiceIssuedTaxInvoice(doReceipt.InvoiceNo, doReceipt.InvoiceOCC); if (isIssuedTaxInvoice == true) { if (param.CancelMethod == CancelReceiptTarget.C_CANCEL_TAX_INVOICE_RECEIPT) { //Cancel tax invoice (Update cancel flag only) isSuccess = billingHandler.CancelTaxInvoice(doReceipt.TaxInvoiceNo); if (!isSuccess) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null); } } else { //Clear receipt no. isSuccess = billingHandler.UpdateReceiptNo(doReceipt.InvoiceNo, doReceipt.InvoiceOCC, null); if (!isSuccess) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null); } } } //Clear receipt no, invoice no of deposit fee if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT && (doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT || doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID)) { isSuccess = billingHandler.UpdateReceiptNoDepositFeeCancelReceipt(doInvoice.InvoiceNo, doReceipt.ReceiptNo , CommonUtil.dsTransData.dtUserData.EmpNo , CommonUtil.dsTransData.dtOperationData.ProcessDateTime); if (!isSuccess) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null); } } //Show attention in case of paid receipt if (doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT || doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK; res.AddErrorMessage(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7030); } //Success scope.Complete(); res.ResultData = "1"; } catch (Exception ex) { scope.Dispose(); throw ex; } } } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Event when click confirm cancel button, this function will cancel the payment matching information of specific invoice no. and inputted cancelling information to the system. /// </summary> /// <param name="param">invoice no. and inputted cancelling information</param> /// <returns></returns> public ActionResult ICS090_cmdConfirmCancel(ICS090_ScreenParameter param) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { if (IsSuspend(res)) { return(Json(res)); } if (!ICS090_IsAllowOperate(res)) { return(Json(res)); } //Validate invoice business ICS090_InvoiceInfo invoiceInfo = ICS090_ValidateInvoiceBusiness(param, res, true); if (res.IsError || invoiceInfo == null || invoiceInfo.doInvoice == null) { return(Json(res)); } //Connect db doInvoice doInvoice = invoiceInfo.doInvoice; using (TransactionScope scope = new TransactionScope()) { try { IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; //Comment by Jutarat A. on 25122013 /*if (doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_NOTE_ENCASHED || doInvoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_POST_ENCASHED) || { #region Encash || || var incomeHandler = ServiceContainer.GetService<IIncomeHandler>() as IIncomeHandler; || bool isSuccess = incomeHandler.CancelPaymentMatching(doInvoice, param.CorrectionReason, param.ApproveNo); || if (!isSuccess) || throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7116, null); || || //Success, return result || scope.Complete(); || res.ResultData = "1"; || return Json(res); #endregion || } || else || {*/ //End Comment #region Other case //Cancel payment matching bool isTaxInvoiceIssued = billingHandler.CheckInvoiceIssuedTaxInvoice(doInvoice.InvoiceNo, doInvoice.InvoiceOCC); var incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler; bool isSuccess = incomeHandler.CancelPaymentMatching(doInvoice, param.CorrectionReason, param.ApproveNo); if (!isSuccess) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7042, null); } //Create new invoice (with pdf) tbt_Invoice doTbt_Invoice = ICS090_CreateNewInvoice(doInvoice, param.CorrectionReason, isTaxInvoiceIssued); if (doTbt_Invoice == null) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7043, null); } //Success, return result scope.Complete(); if ((doTbt_Invoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_FAIL_NOTE_INV_BANK || doTbt_Invoice.InvoicePaymentStatus == PaymentStatus.C_PAYMENT_STATUS_FAIL_CHEQUE_INV_BANK)) { //Success, Display PDF and information ICS090_ScreenParameter screenSession = GetScreenObject <ICS090_ScreenParameter>(); screenSession.PDFFilePath = doTbt_Invoice.FilePath; res.ResultData = "PDF"; return(Json(res)); } else { //Success, Display information popup only res.ResultData = "1"; return(Json(res)); } #endregion //} } catch (Exception ex) { scope.Dispose(); throw ex; } } } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); return(Json(res)); } }