Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        protected override void ProcessReferencePayableInfoForCreate(PayItemInfo entity)
        {
            var now = System.DateTime.Now;
            List <PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo
            {
                OrderSysNo = entity.OrderSysNo,
                OrderType  = entity.OrderType
            });

            if (payList != null && payList.Count > 0)
            {
                ReferencePayableInfo = payList[0];
                if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon)
                {
                    ReferencePayableInfo.OrderAmt           = entity.PayAmt;
                    ReferencePayableInfo.PayStatus          = PayableStatus.UnPay;
                    ReferencePayableInfo.EIMSNo             = null;
                    ReferencePayableInfo.EstimatedTimeOfPay = now;
                    PayableBizProcessor.UpdateStatusAndOrderAmt(ReferencePayableInfo);
                }
                entity.CurrencySysNo = 1;
                entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                entity.OrderType     = ReferencePayableInfo.OrderType;
                entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
            }
            else
            {
                ReferencePayableInfo                    = new PayableInfo();
                ReferencePayableInfo.OrderSysNo         = entity.OrderSysNo.Value;
                ReferencePayableInfo.OrderType          = entity.OrderType.Value;
                ReferencePayableInfo.AlreadyPayAmt      = 0;
                ReferencePayableInfo.OrderAmt           = entity.PayAmt;
                ReferencePayableInfo.CurrencySysNo      = 1;// 人民币类型
                ReferencePayableInfo.PayStatus          = PayableStatus.UnPay;
                ReferencePayableInfo.InvoiceStatus      = PayableInvoiceStatus.Absent;
                ReferencePayableInfo.AuditStatus        = PayableAuditStatus.NotAudit;
                ReferencePayableInfo.InvoiceFactStatus  = PayableInvoiceFactStatus.Corrent;
                ReferencePayableInfo.Note               = "Auto created by system!";
                ReferencePayableInfo.EIMSNo             = null;
                ReferencePayableInfo.EstimatedTimeOfPay = now;
                ReferencePayableInfo.CompanyCode        = entity.CompanyCode;
                ReferencePayableInfo                    = PayableBizProcessor.Create(ReferencePayableInfo);

                entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                entity.CurrencySysNo = 1;
                entity.OrderType     = ReferencePayableInfo.OrderType;
                entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
            }
        }
Exemplo n.º 3
0
        protected override void PreCheckForCreate(PayItemInfo entity)
        {
            base.PreCheckForCreate(entity);

            List<PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo
            {
                OrderSysNo = entity.OrderSysNo,
                OrderType = entity.OrderType
            });
            //如果该单据已经有应付了,对该应付作检查
            if (payList != null && payList.Count > 0)
            {
                ReferencePayableInfo = payList[0];
                if (ReferencePayableInfo.PayStatus == PayableStatus.FullPay)
                {
                    ThrowBizException("PayItem_Create_FullPay");
                }
            }
        }
        protected override void PreCheckForCreate(PayItemInfo entity)
        {
            base.PreCheckForCreate(entity);

            GatherSettlementInfo collectionSettlement = ExternalDomainBroker.GetGatherSettlementInfo(entity.OrderSysNo.Value);

            if (collectionSettlement == null)
            {
                ThrowBizException("PayItem_OrderNotExisitsFormat", entity.OrderSysNo);
            }
            //填写代收结算单上的CompanyCode为付款单CompanyCode
            entity.CompanyCode = collectionSettlement.CompanyCode;
            entity.OrderStatus = (int?)collectionSettlement.SettleStatus;

            if (collectionSettlement.SettleStatus == GatherSettleStatus.SET)
            {
                if (entity.PayStyle != PayItemStyle.Normal)
                {
                    ThrowBizException("PayItem_Create_OnlyCanAddNormalPayForVendorSettleOrder");
                }
            }
            else
            {
                ThrowBizException("PayItem_Create_SettleStatusInvalid");
            }

            List <PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo
            {
                OrderSysNo = entity.OrderSysNo,
                OrderType  = entity.OrderType
            });

            //如果该单据已经有应付了,对该应付作检查
            if (payList != null && payList.Count > 0)
            {
                ReferencePayableInfo = payList[0];
                if (ReferencePayableInfo.PayStatus == PayableStatus.FullPay)
                {
                    ThrowBizException("PayItem_Create_FullPay");
                }
            }
        }
Exemplo n.º 5
0
        protected override void ProcessReferencePayableInfoForCreate(PayItemInfo entity)
        {
            var now = System.DateTime.Now;

            //TODO:为EIMS返点创建付款单时CompanyCode怎么取得。
            //entity.CompanyCode = "8601";
            List <PayableInfo> payList = PayableBizProcessor.GetListByCriteria(new PayableInfo
            {
                OrderSysNo  = entity.OrderSysNo,
                OrderType   = entity.OrderType,
                BatchNumber = entity.BatchNumber
            });

            if (payList != null && payList.Count > 0)
            {
                ReferencePayableInfo = payList[0];
                if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon)
                {
                    ReferencePayableInfo.OrderAmt           = entity.PayAmt;
                    ReferencePayableInfo.PayStatus          = PayableStatus.UnPay;
                    ReferencePayableInfo.EIMSNo             = entity.OrderSysNo.Value;
                    ReferencePayableInfo.EstimatedTimeOfPay = now;

                    PayableBizProcessor.UpdateStatusAndOrderAmt(ReferencePayableInfo);
                }
                entity.CurrencySysNo = ReferencePayableInfo.CurrencySysNo;
                entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                entity.OrderType     = ReferencePayableInfo.OrderType;
                entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
            }
            else
            {
                ReferencePayableInfo                    = new PayableInfo();
                ReferencePayableInfo.OrderSysNo         = entity.OrderSysNo.Value;
                ReferencePayableInfo.OrderType          = entity.OrderType.Value;
                ReferencePayableInfo.AlreadyPayAmt      = 0;
                ReferencePayableInfo.OrderAmt           = entity.PayAmt;
                ReferencePayableInfo.CurrencySysNo      = 1;// 人民币类型
                ReferencePayableInfo.PayStatus          = PayableStatus.UnPay;
                ReferencePayableInfo.InvoiceStatus      = PayableInvoiceStatus.Absent;
                ReferencePayableInfo.AuditStatus        = PayableAuditStatus.NotAudit;
                ReferencePayableInfo.InvoiceFactStatus  = PayableInvoiceFactStatus.Corrent;
                ReferencePayableInfo.EIMSNo             = entity.OrderSysNo.Value;
                ReferencePayableInfo.Note               = "Auto created by system!";
                ReferencePayableInfo.EstimatedTimeOfPay = now;
                ReferencePayableInfo.CompanyCode        = entity.CompanyCode;

                //CRL18977 Added:冲销付款单时,需记录批次号
                ReferencePayableInfo.BatchNumber = entity.BatchNumber;

                //if (ReferencePayableInfo.OrderType == PayableOrderType.SubInvoice) //新建时如果是票扣则ETP不填
                //{
                //    ReferencePayableInfo.EstimatedTimeOfPay = null;
                //}

                ReferencePayableInfo = PayableBizProcessor.Create(ReferencePayableInfo);

                entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                entity.CurrencySysNo = ReferencePayableInfo.CurrencySysNo;
                entity.OrderType     = ReferencePayableInfo.OrderType;
                entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
            }
        }
Exemplo n.º 6
0
        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 如果该单据已经有应付了,对该应付作检查
        }