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); }
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); }
protected virtual PayItemInfo PreCheckForPay(PayItemInfo entity, out PayableInfo payableInfo) { var payItemInfo = PayItemBizProcessor.LoadBySysNo(entity.SysNo.Value); if (payItemInfo.Status != PayItemStatus.Origin) { ThrowBizException("PayItem_Pay_OnlyOriginCanPay"); } payableInfo = PayableBizProcessor.LoadBySysNo(payItemInfo.PaySysNo.Value); //ECC移除应付款汇总表,没有相应的财务审核功能,移除此逻辑 by freegod 20130531 //if (payableInfo.AuditStatus != PayableAuditStatus.Audited) //{ // ThrowBizException("PayItem_Pay_PayableAuditStatusNotMatchAudited"); //} if (payableInfo.PayStatus == PayableStatus.FullPay) { ThrowBizException("PayItem_Pay_CannotPayForFullPay"); } if (payableInfo.PayStatus == PayableStatus.Abandon) { ThrowBizException("PayItem_Pay_CannotPayForAbandon"); } payItemInfo.OrderSysNo = payableInfo.OrderSysNo; payItemInfo.BatchNumber = payableInfo.BatchNumber; 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 override void ProcessReferencePayableInfoForCreate(PayItemInfo entity) { //如果该付款单对应的应付款已经Abandon,那么此时需要重新激活该应付款并将其更新 if (ReferencePayableInfo != null) { if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon) { ReferencePayableInfo.OrderAmt = entity.PayAmt; ReferencePayableInfo.PayStatus = PayableStatus.UnPay; if (entity.OrderType == PayableOrderType.VendorSettleOrder) { ReferencePayableInfo.EIMSNo = ExternalDomainBroker.GetConsignSettlementReturnPointSysNo(entity.OrderSysNo.Value); } else { ReferencePayableInfo.EIMSNo = null; } PayableBizProcessor.UpdateStatusAndOrderAmt(ReferencePayableInfo); entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = 1; entity.OrderType = ReferencePayableInfo.OrderType; entity.OrderSysNo = ReferencePayableInfo.OrderSysNo; } if (ReferencePayableInfo.PayStatus == PayableStatus.UnPay) { entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = 1; 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.CompanyCode = entity.CompanyCode; ReferencePayableInfo = PayableBizProcessor.Create(ReferencePayableInfo); entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = 1; entity.OrderType = ReferencePayableInfo.OrderType; entity.OrderSysNo = ReferencePayableInfo.OrderSysNo; } }
protected override void ProcessReferencePayableInfoForCreate(PayItemInfo entity) { var now = DateTime.Now; //如果该付款单对应的应付款已经Abandon,那么此时需要重新激活该应付款并将其更新 if (ReferencePayableInfo != null) { if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon) { ReferencePayableInfo.OrderAmt = entity.PayAmt; ReferencePayableInfo.PayStatus = PayableStatus.UnPay; ReferencePayableInfo.InStockAmt = entity.InStockAmt; ReferencePayableInfo.EIMSAmt = entity.EIMSAmt; ReferencePayableInfo.RawOrderAmt = entity.RawOrderAmt; CaclETP(entity, now); PayableBizProcessor.UpdateStatusAndOrderAmt(ReferencePayableInfo); } entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = m_POInfo.PurchaseOrderBasicInfo.CurrencyCode; entity.OrderType = ReferencePayableInfo.OrderType; entity.OrderSysNo = ReferencePayableInfo.OrderSysNo; } else { ReferencePayableInfo = new PayableInfo(); ReferencePayableInfo.OrderSysNo = entity.OrderSysNo.Value; ReferencePayableInfo.OrderType = entity.OrderType.Value; ReferencePayableInfo.CurrencySysNo = m_POInfo.PurchaseOrderBasicInfo.CurrencyCode; ReferencePayableInfo.OrderAmt = entity.PayAmt; ReferencePayableInfo.AlreadyPayAmt = 0; ReferencePayableInfo.PayStatus = PayableStatus.UnPay; ReferencePayableInfo.InvoiceStatus = PayableInvoiceStatus.Absent; ReferencePayableInfo.AuditStatus = PayableAuditStatus.NotAudit; ReferencePayableInfo.InvoiceFactStatus = PayableInvoiceFactStatus.Corrent; ReferencePayableInfo.Note = "Auto created by system!"; ReferencePayableInfo.BatchNumber = entity.BatchNumber.HasValue ? entity.BatchNumber : 1; ReferencePayableInfo.EIMSAmt = entity.EIMSAmt; ReferencePayableInfo.InStockAmt = entity.InStockAmt; ReferencePayableInfo.RawOrderAmt = entity.RawOrderAmt; ReferencePayableInfo.OrderStatus = entity.OrderStatus; ReferencePayableInfo.EstimatedTimeOfPay = entity.EstimatedTimeOfPay; ReferencePayableInfo.CompanyCode = entity.CompanyCode; CaclETP(entity, now); ReferencePayableInfo = PayableBizProcessor.Create(ReferencePayableInfo); entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = m_POInfo.PurchaseOrderBasicInfo.CurrencyCode; entity.OrderType = ReferencePayableInfo.OrderType; entity.OrderSysNo = ReferencePayableInfo.OrderSysNo; } }
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; } }
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); }
protected override void ProcessReferencePayableInfoForCreate(PayItemInfo entity) { int currencySysNo = 1; if (ReferencePayableInfo != null) { if (ReferencePayableInfo.PayStatus == PayableStatus.Abandon) { ReferencePayableInfo.OrderAmt = entity.PayAmt; ReferencePayableInfo.PayStatus = PayableStatus.UnPay; ReferencePayableInfo.EIMSNo = null; PayableBizProcessor.UpdateStatusAndOrderAmt(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 = 0; ReferencePayableInfo.OrderAmt = entity.PayAmt; ReferencePayableInfo.CurrencySysNo = currencySysNo; ReferencePayableInfo.PayStatus = PayableStatus.UnPay; ReferencePayableInfo.InvoiceStatus = PayableInvoiceStatus.Absent; ReferencePayableInfo.AuditStatus = PayableAuditStatus.NotAudit; ReferencePayableInfo.InvoiceFactStatus = PayableInvoiceFactStatus.Corrent; ReferencePayableInfo.Note = "Auto created CommissionPayItem!"; ReferencePayableInfo.InStockAmt = 0.00m; ReferencePayableInfo.EstimatedTimeOfPay = DateTime.Now; ReferencePayableInfo.EIMSNo = null; ReferencePayableInfo.CompanyCode = entity.CompanyCode; ReferencePayableInfo = PayableBizProcessor.Create(ReferencePayableInfo); entity.PaySysNo = ReferencePayableInfo.SysNo.Value; entity.CurrencySysNo = currencySysNo; entity.OrderType = ReferencePayableInfo.OrderType; entity.OrderSysNo = ReferencePayableInfo.OrderSysNo; } }
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 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"); } } }
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); }
/// <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); }
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; } }
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; } }
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 如果该单据已经有应付了,对该应付作检查 }