protected virtual PayItemInfo PreCheckForCancelLock(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); //付款状态是否为已锁定 if (payItemInfo.Status != PayItemStatus.Locked) { ThrowBizException("PayItem_UnLock_StatusNotMatchLocked"); } //校验应付款的供应商是否已锁定 if (PayItemBizProcessor.IsHoldByVendor(payItemInfo)) { ThrowBizException("PayItem_UnLock_CannotUnLockByVendor"); } if (PayItemBizProcessor.IsHoldByVendorPM(payItemInfo)) { ThrowBizException("PayItem_UnLock_CannotUnLockByPM"); } payableInfo = PayableBizProcessor.LoadBySysNo(payItemInfo.PaySysNo.Value); //应付款是否为已作废或者已支付 if (payableInfo.PayStatus == PayableStatus.Abandon) { ThrowBizException("PayItem_UnLock_AbandonStatusCannotUnLock"); } else if (payableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_UnLock_FullPayStatusCannotUnLock"); } return(payItemInfo); }
public virtual PayItemInfo Abandon(PayItemInfo entity) { var payItemInfo = PreCheckForAbandon(entity); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadUncommitted; option.Timeout = TransactionManager.DefaultTimeout; var payList = PayableBizProcessor.GetListByCriteria(new PayableInfo { SysNo = payItemInfo.PaySysNo }); bool isLastPayitem = PayItemBizProcessor.IsLastUnAbandon(payItemInfo); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { payItemInfo.Status = PayItemStatus.Abandon; payItemInfo.Note = payItemInfo.Note + entity.Note; PayItemBizProcessor.UpdateStatus(payItemInfo); //如果该应付款对应的所有付款单都是无效的, 就作废应付款 if (isLastPayitem) { foreach (var pay in payList) { pay.PayStatus = PayableStatus.Abandon; PayableBizProcessor.UpdateStatus(pay); } } scope.Complete(); } return(payItemInfo); }
public virtual PayItemInfo CancelAbandon(PayItemInfo entity) { PayableInfo payableInfo = null; var payItemInfo = PreCheckForCancelAbandon(entity, out payableInfo); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { payItemInfo.Status = PayItemStatus.Origin; payItemInfo = PayItemBizProcessor.UpdateStatus(payItemInfo); if (payableInfo.PayStatus == PayableStatus.Abandon) { payableInfo.PayStatus = PayableStatus.UnPay; payableInfo.AlreadyPayAmt = 0; PayableBizProcessor.UpdateStatus(payableInfo); } scope.Complete(); } AfterProcessForCancelAbandon(payItemInfo); return(payItemInfo); }
protected virtual PayItemInfo PreCheckForAbandon(PayItemInfo entity) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); if (payItemInfo.Status != PayItemStatus.Origin) { ThrowBizException("PayItem_Abandon_StatusNotMatchOrigin"); } return(payItemInfo); }
public virtual PayItemInfo CancelPay(PayItemInfo entity) { PayableInfo payableInfo = null; var payItemInfo = PreCheckForCancelPay(entity, out payableInfo); BeforeProcessForCancelPay(payItemInfo); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadUncommitted; option.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { decimal?alreadyPay = payableInfo.AlreadyPayAmt - payItemInfo.PayAmt; decimal?remains = payableInfo.OrderAmt - alreadyPay; if (alreadyPay == 0) { payableInfo.PayStatus = PayableStatus.UnPay; } else if (remains == 0) { payableInfo.PayStatus = PayableStatus.FullPay; } else if ((payableInfo.OrderAmt > 0 && remains > 0) || (payableInfo.OrderAmt < 0 && remains < 0)) { payableInfo.PayStatus = PayableStatus.PartlyPay; } else { payableInfo.PayStatus = PayableStatus.PartlyPay; } payableInfo.AlreadyPayAmt -= payItemInfo.PayAmt; PayableBizProcessor.UpdateStatusAndAlreadyPayAmt(payableInfo); payItemInfo.Status = PayItemStatus.Origin; payItemInfo.BankGLAccount = string.Empty; payItemInfo = PayItemBizProcessor.UpdateStatus(payItemInfo); scope.Complete(); } return(payItemInfo); }
public virtual PayItemInfo CancelLock(PayItemInfo entity) { PayableInfo payableInfo = null; var payItemInfo = PreCheckForCancelLock(entity, out payableInfo); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { payItemInfo.Status = PayItemStatus.Origin; //item.EditUser = entity.EditUser; payItemInfo = PayItemBizProcessor.UpdateStatusAndEditUser(payItemInfo); scope.Complete(); } return(payItemInfo); }
protected virtual PayItemInfo PreCheckForCancelPay(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); if (payItemInfo.Status != PayItemStatus.Paid) { ThrowBizException("PayItem_CancelPay_OnlyPaidCanCancelPay"); } //payItemInfo.PayUserSysNo = entity.PayUserSysNo; payableInfo = PayableBizProcessor.LoadBySysNo(payItemInfo.PaySysNo.Value); payItemInfo.OrderSysNo = payableInfo.OrderSysNo; payItemInfo.BatchNumber = payableInfo.BatchNumber; if (payableInfo.PayStatus == PayableStatus.UnPay || payableInfo.PayStatus == PayableStatus.Abandon) { ThrowBizException("PayItem_CancelPay_CannotCancelPay"); } return(payItemInfo); }
protected virtual PayItemInfo PreCheckForLock(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); if (payItemInfo.Status != PayItemStatus.Origin) { ThrowBizException("PayItem_Lock_StatusNotMatchOrigin"); } payableInfo = PayableBizProcessor.LoadBySysNo(payItemInfo.PaySysNo.Value); //应付款是否为已作废或者已支付 if (payableInfo.PayStatus == PayableStatus.Abandon) { ThrowBizException("PayItem_Lock_AbandonStatusCannotLock"); } else if (payableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_Lock_FullPayStatusCannotLock"); } return(payItemInfo); }
public override PayItemInfo CancelAbandon(PayItemInfo entity) { PayableInfo payableInfo = null; var payItemInfo = base.PreCheckForCancelAbandon(entity, out payableInfo); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { payItemInfo.Status = PayItemStatus.Origin; payItemInfo.Note = payItemInfo.Note + entity.Note; payItemInfo = PayItemBizProcessor.UpdateStatus(payItemInfo); payableInfo.PayStatus = PayableStatus.UnPay; PayableBizProcessor.UpdateStatus(payableInfo); scope.Complete(); } return(payItemInfo); }
protected virtual PayItemInfo PreCheckForCancelAbandon(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); if (payItemInfo.Status != PayItemStatus.Abandon) { ThrowBizException("PayItem_CancelAbandon_StatusNotMatchAbandon"); } payableInfo = PayableBizProcessor.LoadBySysNo(payItemInfo.PaySysNo.Value); if (payableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_CancelAbandon_FullPayCannotCancel"); } payableInfo.PayItemList.Where(x => x.SysNo == entity.SysNo).First().Status = PayItemStatus.Paid; if (payableInfo.PayItemList.Where(x => x.Status != PayItemStatus.Abandon).Sum(x => x.PayAmt) > payableInfo.OrderAmt) { ThrowBizException("PayItem_CancelAbandon_PayItemTotalPayAmtCannotMoreThanPayOrderAmt"); } return(payItemInfo); }
protected override void PreCheckForCreate(PayItemInfo entity) { base.PreCheckForCreate(entity); m_POInfo = ExternalDomainBroker.GetPurchaseOrderInfo(entity.OrderSysNo.Value, 0); if (m_POInfo == null) { ThrowBizException("PayItem_OrderNotExisitsFormat", entity.OrderSysNo); } if (m_POInfo.PurchaseOrderBasicInfo.ConsignFlag == PurchaseOrderConsignFlag.Consign) { ThrowBizException("PayItem_Create_InvalidPOConsignStatus"); } //填写PO的CompanyCode为付款单的CompanyCode entity.CompanyCode = m_POInfo.CompanyCode; entity.OrderStatus = (int?)m_POInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus; if (entity.PayStyle == PayItemStyle.Advanced) { decimal usingReturnPoint = 0M; if (m_POInfo.EIMSInfo != null && m_POInfo.EIMSInfo.EIMSInfoList != null) { usingReturnPoint = m_POInfo.EIMSInfo.EIMSInfoList.Sum(s => s.EIMSAmt ?? 0M); } decimal poTotalAmt = m_POInfo.PurchaseOrderBasicInfo.TotalAmt ?? 0M; if (entity.PayAmt != poTotalAmt - usingReturnPoint) { ThrowBizException("PayItem_Create_AdvancedPayPayedAmtNeedEqualUnPayedAmtFormat", entity.PayAmt.Value.ToString("0.00"), poTotalAmt.ToString("0.00"), usingReturnPoint.ToString("0.00")); } } if (m_POInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus == PurchaseOrderStatus.WaitingInStock) { if (entity.PayStyle != PayItemStyle.Advanced) { ThrowBizException("PayItem_Create_CanOnlyAddAdvancePayItemForPO"); } } else if (m_POInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus == PurchaseOrderStatus.InStocked || m_POInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus == PurchaseOrderStatus.PartlyInStocked) { if (entity.PayStyle != PayItemStyle.Normal) { ThrowBizException("PayItem_Create_CanOnlytAddNormalPayItemForPO"); } } else { ThrowBizException("PayItem_Create_CannotAddPayItemForOtherPOStatus"); } List <PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo { OrderSysNo = entity.OrderSysNo, OrderType = entity.OrderType, BatchNumber = entity.BatchNumber }); #region 如果该单据已经有应付了,对该应付作检查 if (payList != null && payList.Count > 0) { //是否有已作废的应付款 List <PayableInfo> adandonPayList = payList.Where(w => w.PayStatus == PayableStatus.Abandon).ToList(); if (adandonPayList.Count > 0) { ReferencePayableInfo = adandonPayList[0]; } else { ReferencePayableInfo = payList[0]; var payItems = PayItemBizProcessor.GetListByCriteria(new PayItemInfo { PaySysNo = ReferencePayableInfo.SysNo }); payItems.Add(entity); if (payItems.Where(x => x.Status != PayItemStatus.Abandon).Sum(x => x.PayAmt) > ReferencePayableInfo.OrderAmt) { ThrowBizException("PayItem_Create_TotalPayAmtCanNotMoreThanOrderAmt"); } //该检查现阶段只针对PO,因为其他类型单据没有预付款 if (entity.PayStyle == PayItemStyle.Normal) { var list = PayItemBizProcessor.GetListByCriteria(new PayItemInfo { Status = PayItemStatus.Origin, PayStyle = PayItemStyle.Advanced, PaySysNo = ReferencePayableInfo.SysNo }); if (list != null && list.Count > 0) { ThrowBizException("PayItem_Create_AdvancedPayItemExists"); } } if (ReferencePayableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_Create_FullPay"); } } } #endregion 如果该单据已经有应付了,对该应付作检查 }