Exemplo n.º 1
0
        public async Task RegistrarRecebimentoNotaFiscal(long idNotaFiscal, string userId, DateTime dataRecebimento, int?qtdVolumes = null)
        {
            var loteService = new LoteService(_uow, _log);

            var notafiscal = _uow.NotaFiscalRepository.GetById(idNotaFiscal);

            await VerificarNotaFiscalCancelada(notafiscal.CodigoIntegracao);

            Lote lote = _uow.LoteRepository.GetById(idNotaFiscal);

            if (lote != null)
            {
                throw new BusinessException(string.Format("Já existe um lote criado para a Nota Fiscal {0}, portanto o recebimento não pode ser efetuado", idNotaFiscal));
            }

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["IntegracaoSankhya_Habilitar"]))//TODO Temporário
            {
                await AtualizarNotaFiscalIntegracao(notafiscal, LoteStatusEnum.Recebido);
            }

            using (TransactionScope transactionScope = _uow.CreateTransactionScope())
            {
                loteService.CriarLoteRecebimento(notafiscal, userId, dataRecebimento, qtdVolumes);

                notafiscal.IdNotaFiscalStatus = NotaFiscalStatusEnum.Recebida;

                _uow.SaveChanges();
                transactionScope.Complete();
            }
        }
Exemplo n.º 2
0
 public ConferenciaService(UnitOfWork uow, LoteService loteService)
 {
     _uow                = uow;
     _loteService        = loteService;
     conferenciaResponse = new ConferenciaResponse();
 }