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); }
/// <summary> /// 支付付款单 /// </summary> /// <param name="payItemInfo">付款单</param> /// <param name="payableInfo">付款单对应的应付款</param> /// <param name="isForcePay">是否强制付款</param> /// <returns>支付后的付款单</returns> public virtual PayItemInfo Pay(PayItemInfo entity, bool isForcePay) { PayableInfo payableInfo = null; var payItemInfo = PreCheckForPay(entity, out payableInfo); BeforeProcessForPay(payItemInfo); //执行业务操作 TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadUncommitted; option.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { decimal alreadyPay = payItemInfo.PayAmt.Value + payableInfo.AlreadyPayAmt.Value; decimal remains = payableInfo.OrderAmt.Value - alreadyPay; if (remains == 0) { payableInfo.PayStatus = PayableStatus.FullPay; //对于一个PO单对应的付款状态为FullPay的应付款,如果这个PO单对应的应付款有存在付款状态为Origin的付款单, //系统自动将这些付款单的付款状态从Origin置为Abandon //if (payableInfo.OrderType != PayableOrderType.SubInvoice) { PayItemBizProcessor.SetAbandonOfFullPay(payItemInfo); } } else if ((payableInfo.OrderAmt > 0 && remains > 0) || (payableInfo.OrderAmt < 0 && remains < 0)) { payableInfo.PayStatus = PayableStatus.PartlyPay; } else { if (isForcePay) { payableInfo.PayStatus = PayableStatus.FullPay; //对于一个PO单对应的付款状态为FullPay的应付款,如果这个PO单对应的应付款有存在付款状态为Origin的付款单, //系统自动将这些付款单的付款状态从Origin置为Abandon //if (payableInfo.OrderType != PayableOrderType.SubInvoice) { PayItemBizProcessor.SetAbandonOfFullPay(payItemInfo); } } else { ThrowBizException("PayItem_Pay_CannotPayForMore"); } } payableInfo.AlreadyPayAmt += payItemInfo.PayAmt; PayableBizProcessor.UpdateStatusAndAlreadyPayAmt(payableInfo); payItemInfo.Status = PayItemStatus.Paid; payItemInfo.BankGLAccount = entity.BankGLAccount; payItemInfo = PayItemBizProcessor.UpdateStatus(payItemInfo); scope.Complete(); } return(payItemInfo); }