Exemplo n.º 1
0
        public virtual void CreateByVendor(PayableInfo entity)
        {
            if (!entity.EIMSAmt.HasValue)
            {
                entity.EIMSAmt = 0;
            }
            if (!entity.InStockAmt.HasValue)
            {
                entity.InStockAmt = 0;
            }

            //PO调整单
            if (entity.OrderType == PayableOrderType.POAdjust)
            {
                CreatePOAdjustByVendor(entity);
            }
            else if (entity.OrderType == PayableOrderType.PO)
            {
                #region CRL17366 代销采购单不生成付款单

                var poEntity = ExternalDomainBroker.GetPurchaseOrderInfo(entity.OrderSysNo.Value, entity.BatchNumber.Value);
                if (poEntity != null && poEntity.PurchaseOrderBasicInfo.ConsignFlag == PurchaseOrderConsignFlag.Consign)
                {
                    return;
                }

                #endregion CRL17366 代销采购单不生成付款单

                entity.EstimatedTimeOfPay = ETPCalculatorHelper.GetETPByPayPeriod(entity, DateTime.MinValue);

                //获取付款时间
                DateTime payTime = DateTime.MinValue;
                var      result  = ObjectFactory <PayItemProcessor> .Instance.GetListByCriteria(new PayItemInfo
                {
                    OrderSysNo = entity.OrderSysNo.Value,
                    OrderType  = entity.OrderType,
                    Status     = PayItemStatus.Paid
                });

                if (result.Count > 0 && result[0].PayTime.HasValue)
                {
                    payTime = result[0].PayTime.Value;
                }
                PrePayPOByVendor(entity);
            }
        }
        protected override void ProcessReferencePayableInfoForCreate(PayItemInfo entity)
        {
            int currencySysNo = 1;

            if (ReferencePayableInfo != null)
            {
                //如果该付款单对应的应付款已经Abandon,那么此时需要重新激活该应付款并将其更新
                if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon)
                {
                    ReferencePayableInfo.OrderAmt  = entity.PayAmt;
                    ReferencePayableInfo.PayStatus = PayableStatus.UnPay;
                    ReferencePayableInfo.EIMSNo    = null;

                    PayableBizProcessor.UpdateStatusAndOrderAmt(ReferencePayableInfo);

                    //计算ETP
                    ReferencePayableInfo.EstimatedTimeOfPay = ETPCalculatorHelper.GetETPByPayPeriod(new PayableInfo
                    {
                        OrderType  = PayableOrderType.CollectionSettlement,
                        OrderSysNo = entity.OrderSysNo.Value
                    }, DateTime.Now);
                    PayableBizProcessor.UpdatePayableETP(ReferencePayableInfo);

                    entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                    entity.CurrencySysNo = currencySysNo;
                    entity.OrderType     = ReferencePayableInfo.OrderType;
                    entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
                }

                if (ReferencePayableInfo.PayStatus == PayableStatus.UnPay)
                {
                    //计算ETP
                    ReferencePayableInfo.EstimatedTimeOfPay = ETPCalculatorHelper.GetETPByPayPeriod(new PayableInfo
                    {
                        OrderType  = PayableOrderType.CollectionSettlement,
                        OrderSysNo = entity.OrderSysNo.Value
                    }, DateTime.Now);
                    PayableBizProcessor.UpdatePayableETP(ReferencePayableInfo);

                    entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                    entity.CurrencySysNo = currencySysNo;
                    entity.OrderType     = ReferencePayableInfo.OrderType;
                    entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
                }
            }
            else
            {
                ReferencePayableInfo                   = new PayableInfo();
                ReferencePayableInfo.OrderSysNo        = entity.OrderSysNo.Value;
                ReferencePayableInfo.OrderType         = entity.OrderType.Value;
                ReferencePayableInfo.AlreadyPayAmt     = 0M;
                ReferencePayableInfo.OrderAmt          = entity.PayAmt;
                ReferencePayableInfo.CurrencySysNo     = currencySysNo;
                ReferencePayableInfo.PayStatus         = PayableStatus.UnPay;
                ReferencePayableInfo.InvoiceStatus     = PayableInvoiceStatus.Absent;
                ReferencePayableInfo.AuditStatus       = PayableAuditStatus.NotAudit;
                ReferencePayableInfo.InvoiceFactStatus = PayableInvoiceFactStatus.Corrent;
                ReferencePayableInfo.InStockAmt        = 0M;
                ReferencePayableInfo.Note              = "Auto created CollectionSettlementPayItem!";
                ReferencePayableInfo.CompanyCode       = entity.CompanyCode;

                //计算ETP
                ReferencePayableInfo.EstimatedTimeOfPay = ETPCalculatorHelper.GetETPByPayPeriod(new PayableInfo
                {
                    OrderType  = PayableOrderType.CollectionSettlement,
                    OrderSysNo = entity.OrderSysNo.Value
                }, DateTime.Now);
                ReferencePayableInfo.EIMSNo = null;
                ReferencePayableInfo        = PayableBizProcessor.Create(ReferencePayableInfo);

                entity.PaySysNo      = ReferencePayableInfo.SysNo.Value;
                entity.CurrencySysNo = currencySysNo;
                entity.OrderType     = ReferencePayableInfo.OrderType;
                entity.OrderSysNo    = ReferencePayableInfo.OrderSysNo;
            }
        }