/// <summary> /// 提交发票 Pwp 2015-10-08 /// </summary> /// <param name="contractview"></param> /// <returns></returns> public void AddCollectInvoice(CollectInvoiceAddModel contractview) { Payment mPayment = _paymentRepository.GetModel(o => o.ID == contractview.PaymentID).FirstOrDefault(); if (mPayment.Money > contractview.Money) throw new BusinessException(string.Format(BusinessResourceMessage.ItemComparison, "付款金额", "收票金额")); //付款发票 CollectInvoice mCollectInvoice = new CollectInvoice(); mCollectInvoice.PaymentId = contractview.PaymentID; mCollectInvoice.Status = CollectInvoiceStatus.WaitVerify; mCollectInvoice.Remark = contractview.Remark; mCollectInvoice.CreaterId = contractview.OperatorID; mCollectInvoice.CreateTime = contractview.OptionTime; TransactionScopeNoMsdtc.UsingTransactionNoMsdtc(_db, () => { _collectinvoiceRepository.Insert(mCollectInvoice); foreach (CollectInvoiceAddModelGroup tempGroup in contractview.Group) { CollectInvoiceGroup mCollectInvoiceGroup = new CollectInvoiceGroup(); mCollectInvoiceGroup.CollectInvoiceId = mCollectInvoice.ID; mCollectInvoiceGroup.GroupCode = tempGroup.Code; mCollectInvoiceGroup.Name = tempGroup.Name; _collectinvoicegroupRepository.Insert(mCollectInvoiceGroup); foreach (CollectInvoiceAddModelInfo tempInfo in tempGroup.Info) { CollectInvoiceDetail mCollectInvoiceDetail = new CollectInvoiceDetail(); mCollectInvoiceDetail.CollectInvoiceId = mCollectInvoice.ID; mCollectInvoiceDetail.GroupId = mCollectInvoiceGroup.ID; mCollectInvoiceDetail.Code = tempInfo.Code; mCollectInvoiceDetail.Money = tempInfo.Money; mCollectInvoiceDetail.Date = tempInfo.Date; mCollectInvoiceDetail.Content = tempInfo.Content; _collectinvoicedetailRepository.Insert(mCollectInvoiceDetail); } } }); }
public DataResult AddCollectInvoice(CollectInvoiceAddModel inputcontract) { #region 角色验证 if (LoginUser.Type != 0 && LoginUser.Type != UserType.SpecialLine) { throw new DataOperationPermissions(BusinessResourceMessage.NoPower); } #endregion #region 输入验证 decimal deMoney = 0; if (inputcontract.PaymentID == 0) throw new DataValidationException(string.Format(BusinessResourceMessage.Inexistent, "付款")); //if (inputcontract.SpecialId == 0) // throw new DataValidationException(string.Format(BusinessResourceMessage.Inexistent, "专线")); //if (inputcontract.SupplyId == 0) // throw new DataValidationException(string.Format(BusinessResourceMessage.Inexistent, "供应商")); //if (!CommonValidator.isMoney(inputcontract.Money.ToString())) // throw new DataValidationException(string.Format(BusinessResourceMessage.ItemFormatError, "付款金额")); if (inputcontract.Group.Count<1) throw new DataValidationException(string.Format(BusinessResourceMessage.PleaseInput, "团信息")); foreach (CollectInvoiceAddModelGroup groupTemp in inputcontract.Group) { if (string.IsNullOrEmpty(groupTemp.Code)) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemCanNotNull, "团号")); if (groupTemp.Code.Length > 20) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemLenError, "团号", "20")); if (string.IsNullOrEmpty(groupTemp.Name)) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemCanNotNull, "团名称")); if (groupTemp.Name.Length > 100) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemLenError, "团名称", "100")); if (groupTemp.Info.Count < 1) throw new DataValidationException(string.Format(BusinessResourceMessage.PleaseInput, "发票")); foreach (CollectInvoiceAddModelInfo infoTemp in groupTemp.Info) { if (string.IsNullOrEmpty(infoTemp.Code)) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemCanNotNull, "发票编号")); if (infoTemp.Code.Length > 50) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemLenError, "发票编号", "50")); if (string.IsNullOrEmpty(infoTemp.Content)) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemCanNotNull, "发票科目")); if (!CommonValidator.isMoney(infoTemp.Money.ToString())) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemFormatError, "发票金额")); if (!CommonValidator.isDateTime(infoTemp.Date.ToString())) throw new DataValidationException(string.Format(BusinessResourceMessage.ItemFormatError, "发票日期")); deMoney += infoTemp.Money; } } #endregion inputcontract.Money = deMoney; inputcontract.OperatorID = LoginUser.ID; inputcontract.OperatorName = LoginUser.Name; inputcontract.OptionTime = DateTime.Now; collectinvoiceService.AddCollectInvoice(inputcontract); dataResult.Code = ResponseStatusCode.Success; dataResult.Msg = BusinessResourceMessage.Success; return dataResult; }