//se Possuir uma compra, não pode cancelar
        public void Cancelar(CancelarContaPagar model)
        {
            var compra = this.CompraDAO.GetByID(new DTO.Compras.CompraId()
            {
                Serie        = model.Serie,
                Modelo       = model.Modelo,
                Numero       = model.Numero,
                FornecedorId = model.FornecedorId
            });

            if (compra != null)
            {
                throw new BusinessException(new { Numero = "Não é possível cancelar uma conta a pagar lançada por uma compra" });
            }

            var result = this.UserDAO.PasswordSignIn(this.UserRequest.UserNome, model.Senha);

            if (!result.Succeeded)
            {
                throw new BusinessException(new { Senha = "Senha inválido" });
            }

            var entity = this.ContaPagarDAO.GetByID(model.GetId());

            if (entity == null)
            {
                throw new BusinessException(new { Parcela = "Conta a pagar não cadastrada." });
            }

            entity.JustificativaCancelamento = model.Justificativa;
            entity.UserCancelamento          = this.UserRequest.Id.ToString();
            entity.DataCancelamento          = DateTime.Now;

            this.ContaPagarDAO.Update(entity);
        }
        internal void CancelarBaixa(CancelarContaPagar model)
        {
            var entity = this.ContaPagarDAO.GetByID(model.GetId());

            if (entity == null)
            {
                throw new BusinessException(new { Parcela = "Conta a pagar não cadastrada." });
            }

            var login = UserDAO.PasswordSignIn(this.UserRequest.UserNome, model.Senha);

            if (!login.Succeeded)
            {
                throw new BusinessException(new { senha = "Senha inválida" });
            }

            entity.DataBaixa     = null;
            entity.UserBaixa     = null;
            entity.DataPagamento = null;
            entity.ValorBaixa    = null;

            entity.JustificativaCancelamentoBaixa = model.Justificativa;
            entity.UserCancelamentoBaixa          = this.UserRequest.Id.ToString();
            entity.DataCancelamentoBaixa          = DateTime.Now;

            this.ContaPagarDAO.Update(entity);
        }
Esempio n. 3
0
        public virtual IActionResult CancelarBaixa([FromRoute] ContaPagarId id, CancelarContaPagar cancelarContaPagar)
        {
            cancelarContaPagar.Modelo       = id.Modelo;
            cancelarContaPagar.Serie        = id.Serie;
            cancelarContaPagar.Numero       = id.Numero;
            cancelarContaPagar.FornecedorId = id.FornecedorId;
            cancelarContaPagar.Parcela      = id.Parcela;

            this.ContaPagarService.CancelarBaixa(cancelarContaPagar);

            return(Ok());
        }