Ejemplo n.º 1
0
        /// <summary>
        /// 代收结算单 - 取消结算
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public GatherSettlementInfo CancelSettleGatherSettlement(GatherSettlementInfo info)
        {
            //1 检查当前结算单状态
            if (info.SettleStatus != GatherSettleStatus.SET)
            {
                //当前结算单的状态不为已结算状态!
                throw new BizException(GetMessageString("Gather_Settle_Invalid"));
            }
            ////2 检查付款单是否作废,如果付款单未作废抛出异常(调用Invoice接口)
            if (!ExternalDomainBroker.IsAbandonGatherPayItem(info.SysNo.Value))
            {
                throw new BizException(GetMessageString("Gather_Settle_Abandon_CancelSettle"));
            }

            GatherSettlementInfo oldSettle = GatherSettlementDA.GetVendorSettleGatherInfo(info);

            if (info.SettleStatus != GatherSettleStatus.SET)
            {
                //该结算单不是已结算状态,不能进行取消结算操作!
                throw new BizException(GetMessageString("Gather_Settle_Invalid_CancelSettle"));
            }

            info.SettleStatus = GatherSettleStatus.AUD;
            GatherSettlementDA.UpdateGatherSettlementStatus(info, false);

            //发送取消结算Message
            EventPublisher.Publish(new GatherSettlementSettleCanceledMessage()
            {
                SettlementSysNo  = info.SysNo.Value,
                CurrentUserSysNo = ServiceContext.Current.UserSysNo
            });

            //写LOG:CommonService.WriteLog<VendorSettleGatherEntity>(entity, " CancelSettled Gather ", entity.SysNo.Value.ToString(), (int)LogType.Purchase_Verify_InStock);

            ExternalDomainBroker.CreateLog(" CancelSettled Gather "
                                           , BizEntity.Common.BizLogType.Purchase_Verify_InStock
                                           , info.SysNo.Value
                                           , info.CompanyCode);

            return(info);
        }