Exemplo n.º 1
0
        public BE_Json reversePayment(BE_PaymentAuth bePaymentAuth)
        {
            //BL_Payment _blPayment = new BL_Payment();
            //_blPayment.connectionString = AppConfig.DbConnection;
            //return _blPayment.reversePayment(bePaymentAuth, bePaymentAuth.userName);

            BE_Json objJson     = null;
            var     objListaAux = string.Empty;

            try
            {
                BL_Payment _blPayment = new BL_Payment();
                _blPayment.connectionString = AppConfig.DbConnection;
                objListaAux = JsonConvert.SerializeObject(_blPayment.reversePayment(bePaymentAuth));

                objJson        = new BE_Json();
                objJson.data   = objListaAux;
                objJson.status = CManager.RESULTADO_WCF.OK;
            }
            catch (Exception ex)
            {
                objJson        = new BE_Json();
                objJson.data   = "Hubo en error en servidor:" + ex.Message + ";" + ex.StackTrace + ";" + ex.ToString();
                objJson.status = CManager.RESULTADO_WCF.ERROR;
                objJson.status = CManager.RESULTADO_WCF.ERROR;
            }
            finally
            {
                objListaAux = null;
            }
            return(objJson);
        }
Exemplo n.º 2
0
        // second user
        public BE_PaymentAuth updateUserAuth(BE_PaymentAuth _paymentAuth, string userId)
        {
            _database = new MySQLDatabase(connectionString);
            if (!string.IsNullOrEmpty(_paymentAuth.thirdUserId))
            {
            }

            return(new DA_Payment(_database).updateUserAuth(_paymentAuth, userId));
        }
Exemplo n.º 3
0
        public BE_Payment CreateAdvance(BE_Payment _BePayment)
        {
            _database = new MySQLDatabase(connectionString);
            BE_PaymentAuth       _PaymentAuth       = new BE_PaymentAuth();
            BE_PaymentAuthDetail _paymentAuthDetail = new BE_PaymentAuthDetail();

            _PaymentAuth = new BE_PaymentAuth();
            _PaymentAuth.bankAccountId = (int)_BePayment.bankAccountId;
            _PaymentAuth.companyCode   = _BePayment.companyCode;
            _PaymentAuth.userName      = _BePayment.userName;
            _PaymentAuth.exchangeRate  = _BePayment.exchangeRate == null ? 0 : decimal.Parse(_BePayment.exchangeRate);

            var aux = new DA_Payment(_database).createPaymentAuth(_PaymentAuth);

            _BePayment.paymentAuthId = aux.paymentAuthId;
            var aux2 = new DA_Payment(_database).createPaymentGeneral(_BePayment);

            _BePayment.paymentId = aux2.paymentId;

            BE_PaymentDetail bE_PaymentDetail = new BE_PaymentDetail();

            bE_PaymentDetail.idPayment = int.Parse(_BePayment.paymentId.ToString());
            bE_PaymentDetail.amount    = _BePayment.amountTotal;

            new DA_Payment(_database).CreatePaymentDetail(bE_PaymentDetail);
            new DA_Bank(_database).updateBalanceBankAccountByPayment((int)_BePayment.paymentId, _BePayment.bankAccountId);

            _paymentAuthDetail = new BE_PaymentAuthDetail();
            _paymentAuthDetail.paymentAuthId = (int)_BePayment.paymentAuthId;
            _paymentAuthDetail.userAudit     = _BePayment.userName;
            _paymentAuthDetail = new DA_Payment(_database).createFirstPAD(_paymentAuthDetail);

            if (aux != null && aux2 != null)
            {
                return(_BePayment);
            }
            else
            {
                throw new Exception("Ocurrió un error al realizar la transacción");
            }
        }
Exemplo n.º 4
0
 public BE_PaymentAuth reversePayment(BE_PaymentAuth bePaymentAuth)
 {
     _database = new MySQLDatabase(connectionString);
     //new DA_Payment(_database).reversePaymentAuth(bePaymentAuth);
     return(new DA_Payment(_database).reversePayment(bePaymentAuth));
 }
Exemplo n.º 5
0
        public List <VE_Invoice> MakePaymentsDetailsPartials(List <VE_Invoice> _lstVeInvoice, BE_Payment _BePayment)
        {
            _database = new MySQLDatabase(connectionString);

            BE_PaymentAuthDetail _paymentAuthDetail = new BE_PaymentAuthDetail();

            BE_PaymentAuth _PaymentAuth = new BE_PaymentAuth();


            BL_WorkFlow _blWorkFlow = new BL_WorkFlow();

            _blWorkFlow.connectionString = connectionString;

            /*
             * foreach (VE_Invoice _veInvoice in _lstVeInvoice)
             * {
             *  _blWorkFlow = new BL_WorkFlow();
             *  _blWorkFlow.connectionString = connectionString;
             *  var mensaje = "";
             *  bool bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_veInvoice.invoiceId), _veInvoice.userName, false);
             *  //bool bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_veInvoice.invoiceId), "marko.polo", false);
             *
             *  if (!bOk)
             *  {
             *      throw new Exception(mensaje);
             *
             *  }
             * }
             */
            _PaymentAuth = new BE_PaymentAuth();
            _PaymentAuth.bankAccountId = (int)_BePayment.bankAccountId;
            _PaymentAuth.companyCode   = _BePayment.companyCode;
            _PaymentAuth.userName      = _BePayment.userName;
            _PaymentAuth.exchangeRate  = _BePayment.exchangeRate == null ? 0 : decimal.Parse(_BePayment.exchangeRate);

            var aux = new DA_Payment(_database).createPaymentAuth(_PaymentAuth);

            _BePayment.paymentAuthId = aux.paymentAuthId;
            var aux2 = new DA_Payment(_database).createPaymentGeneral(_BePayment);

            _BePayment.paymentId = aux2.paymentId;


            foreach (VE_Invoice _veInvoice in _lstVeInvoice)
            {
                BE_PaymentDetail bE_PaymentDetail = new BE_PaymentDetail();
                bE_PaymentDetail.idPayment = int.Parse(_BePayment.paymentId.ToString());
                bE_PaymentDetail.idInvoice = int.Parse(_veInvoice.invoiceId);
                bE_PaymentDetail.amount    = _veInvoice.amountPayment;

                new DA_Payment(_database).CreatePaymentDetail(bE_PaymentDetail);
                new DA_Bank(_database).updateBalanceBankAccountByPayment((int)_BePayment.paymentId, _BePayment.bankAccountId);

                _paymentAuthDetail = new BE_PaymentAuthDetail();
                _paymentAuthDetail.paymentAuthId = (int)_BePayment.paymentAuthId;
                _paymentAuthDetail.userAudit     = _BePayment.userName;
                _paymentAuthDetail = new DA_Payment(_database).createFirstPAD(_paymentAuthDetail);
            }

            if (aux != null)
            {
                return(_lstVeInvoice);
            }
            else
            {
                throw new Exception("Ocurrió un error al realizar la transacción");
            }
        }
Exemplo n.º 6
0
        public List <BE_Invoice> MakePaymentsDetails(List <VE_Invoice> _lstVeInvoice)
        {
            _database = new MySQLDatabase(connectionString);
            List <BE_Invoice>     _lstBeInvoice      = new List <BE_Invoice>();
            List <BE_PaymentAuth> _lstPaymentAuth    = new List <BE_PaymentAuth>();
            List <BE_PaymentAuth> _lstPaymentAuthAux = new List <BE_PaymentAuth>();
            BE_Payment            _payment           = new BE_Payment();
            BE_Invoice            _beInvoice         = new BE_Invoice();
            BE_PaymentAuthDetail  _paymentAuthDetail = new BE_PaymentAuthDetail();

            BL_WorkFlow _blWorkFlow = new BL_WorkFlow();

            _blWorkFlow.connectionString = connectionString;


            foreach (VE_Invoice _veInvoice in _lstVeInvoice)
            {
                _blWorkFlow = new BL_WorkFlow();
                _blWorkFlow.connectionString = connectionString;
                var  mensaje = "";
                bool bOk     = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_veInvoice.invoiceId), _veInvoice.userName, false);
                //bool bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_veInvoice.invoiceId), "marko.polo", false);

                if (!bOk)
                {
                    throw new Exception(mensaje);
                }
            }

            foreach (VE_Invoice _veInvoice in _lstVeInvoice)
            {
                if (_lstPaymentAuth.Count() == 0)
                {
                    BE_PaymentAuth _PaymentAuth = new BE_PaymentAuth();
                    _PaymentAuth.bankAccountId = _veInvoice.bankAccountId;
                    _PaymentAuth.companyCode   = _veInvoice.companyCode;
                    _PaymentAuth.userName      = _veInvoice.userName;
                    //_PaymentAuth.userName = "";
                    _PaymentAuth.exchangeRate = _veInvoice.exchangeRate == null ? 0 : decimal.Parse(_lstVeInvoice[0].exchangeRate);
                    _lstPaymentAuthAux.Add(_PaymentAuth);
                    _lstPaymentAuth.AddRange(_lstPaymentAuthAux);
                }
                else
                {
                    var cont = 0;
                    foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
                    {
                        cont++;
                        if (bE_PaymentAuth.bankAccountId != _veInvoice.bankAccountId && cont == _lstPaymentAuth.Count())
                        {
                            BE_PaymentAuth _PaymentAuth = new BE_PaymentAuth();
                            _PaymentAuth.bankAccountId = _veInvoice.bankAccountId;
                            _PaymentAuth.companyCode   = _veInvoice.companyCode;
                            _PaymentAuth.userName      = _veInvoice.userName;
                            //_PaymentAuth.userName = "";
                            _PaymentAuth.exchangeRate = _veInvoice.exchangeRate == null ? 0 : decimal.Parse(_lstVeInvoice[0].exchangeRate);
                            _lstPaymentAuthAux.Add(_PaymentAuth);
                        }
                    }
                    _lstPaymentAuth = new List <BE_PaymentAuth>();
                    _lstPaymentAuth.AddRange(_lstPaymentAuthAux);
                }
            }
            _lstPaymentAuthAux = new List <BE_PaymentAuth>();
            foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
            {
                var aux = new DA_Payment(_database).createPaymentAuth(bE_PaymentAuth);

                _lstPaymentAuthAux.Add(aux);
            }
            _lstPaymentAuth = new List <BE_PaymentAuth>();
            _lstPaymentAuth.AddRange(_lstPaymentAuthAux);

            foreach (VE_Invoice _veInvoice in _lstVeInvoice)
            {
                _beInvoice = GetInvoiceById(_veInvoice.invoiceId);
                _lstBeInvoice.Add(new DA_Invoice(_database).payInvoviceDetail(_veInvoice));

                var cont = 0;
                foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
                {
                    cont++;
                    if (bE_PaymentAuth.bankAccountId == _veInvoice.bankAccountId)
                    {
                        bE_PaymentAuth.amountPaid           += _beInvoice.amountBalance;
                        bE_PaymentAuth.amountPaidPen        += _beInvoice.amountPaymentPen;
                        bE_PaymentAuth.amountDetractionPaid += _beInvoice.amountPaymentDetraction;

                        _payment = new BE_Payment();
                        _payment.paymentAuthId     = bE_PaymentAuth.paymentAuthId;
                        _payment.id                = _veInvoice.invoiceId;
                        _payment.bankId            = _veInvoice.bankId;
                        _payment.bankAccountId     = _veInvoice.bankAccountId;
                        _payment.bankAccountNumber = _veInvoice.bankAccountNumber;
                        _payment.userName          = _veInvoice.userName;
                        //_payment.userName = "";
                        _payment = new DA_Payment(_database).createPayment(_payment);


                        BE_PaymentDetail bE_PaymentDetail = new BE_PaymentDetail();
                        bE_PaymentDetail.idPayment = int.Parse(_payment.paymentId.ToString());
                        bE_PaymentDetail.idInvoice = int.Parse(_payment.id);
                        bE_PaymentDetail.amount    = _beInvoice.amountTotal;

                        new DA_Payment(_database).CreatePaymentDetail(bE_PaymentDetail);
                        new DA_Bank(_database).updateBalanceBankAccountByInvoice(int.Parse(_beInvoice.invoiceId), _veInvoice.bankAccountId);

                        _paymentAuthDetail = new BE_PaymentAuthDetail();
                        _paymentAuthDetail.paymentAuthId = bE_PaymentAuth.paymentAuthId;
                        _paymentAuthDetail.userAudit     = _veInvoice.userName;
                        //_paymentAuthDetail.userAudit = "";
                        _paymentAuthDetail = new DA_Payment(_database).createFirstPAD(_paymentAuthDetail);
                    }
                }
            }

            foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
            {
                var aux = new DA_Payment(_database).updatePaymentAuth(bE_PaymentAuth);
                _lstPaymentAuthAux = new List <BE_PaymentAuth>();
                _lstPaymentAuthAux.Add(aux);
            }
            _lstPaymentAuth = _lstPaymentAuthAux;
            if (_lstBeInvoice.Count > 0 && _payment != null && _lstPaymentAuth != null)
            {
                return(_lstBeInvoice);
            }
            else
            {
                throw new Exception("Ocurrió un error al realizar la transacción");
            }
        }
Exemplo n.º 7
0
        /*public List<BE_Invoice> MakePayments(List<VE_Invoice> _lstVeInvoice)
         * {
         *  _database = new MySQLDatabase(connectionString);
         *  if (_lstVeInvoice.Count == 0)
         *  {
         *      throw new Exception("La lista enviada no contiene elementos");
         *  }
         *
         *  List<BE_Invoice> _lstBeInvoice = new List<BE_Invoice>();
         *  BE_PaymentAuth _paymentAuth = new BE_PaymentAuth();
         *  BE_Payment _payment = new BE_Payment();
         *  BE_PaymentAuthDetail _paymentAuthDetail = new BE_PaymentAuthDetail();
         *  BL_WorkFlow _blWorkFlow = new BL_WorkFlow();
         *  BL_Usuario bL_Usuario = new BL_Usuario();
         *  bL_Usuario.connectionString = connectionString;
         *  List<BE_User> bE_Users = new List<BE_User>();
         *
         *  foreach (VE_Invoice _veInvoice in _lstVeInvoice)
         *  {
         *      _lstBeInvoice.AddRange(new DA_Invoice(_database).getInvoiceToPayBySum(_veInvoice));
         *      bE_Users.AddRange(bL_Usuario.GetUserGeneral(new BE_UserFilter { id = _veInvoice.userId }));
         *  }
         *
         *  if (_lstBeInvoice.Count > 0)
         *  {
         *      foreach (BE_Invoice _beInvoice in _lstBeInvoice)
         *      {
         *          _blWorkFlow = new BL_WorkFlow();
         *          _blWorkFlow.connectionString = connectionString;
         *          var mensaje = "";
         *          bool bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_beInvoice.invoiceId), bE_Users[0].userName, false);
         *
         *          if (!bOk)
         *          {
         *              throw new Exception(mensaje);
         *
         *          }
         *      }
         *
         *      foreach (BE_Invoice _beInvoice in _lstBeInvoice)
         *      {
         *          _paymentAuth.amountPaid += _beInvoice.amountBalance;
         *          _paymentAuth.amountPaidPen += _beInvoice.amountPaymentPen;
         *          _paymentAuth.amountDetractionPaid += _beInvoice.amountPaymentDetraction;
         *      }
         *
         *      _paymentAuth.bankAccountId = _lstVeInvoice[0].bankAccountId;
         *      _paymentAuth.companyCode = _lstVeInvoice[0].companyCode;
         *      _paymentAuth.exchangeRate = _lstBeInvoice[0].exchangeRate == null ? 0 : decimal.Parse(_lstBeInvoice[0].exchangeRate);
         *      _paymentAuth = new DA_Payment(_database).createPaymentAuth(_paymentAuth);
         *
         *      foreach (BE_Invoice _beInvoice in _lstBeInvoice)
         *      {
         *          _beInvoice.bankId = _lstVeInvoice[0].bankId;
         *          _beInvoice.bankAccountId = _lstVeInvoice[0].bankAccountId;
         *          _beInvoice.bankAccountNumber = _lstVeInvoice[0].bankAccountNumber;
         *          new DA_Invoice(_database).payInvovice(_beInvoice);
         *
         *          _payment = new BE_Payment();
         *          _payment.paymentAuthId = _paymentAuth.paymentAuthId;
         *          _payment.id = _beInvoice.invoiceId;
         *          _payment.bankId = _lstVeInvoice[0].bankId;
         *          _payment.bankAccountId = _lstVeInvoice[0].bankAccountId;
         *          _payment.bankAccountNumber = _lstVeInvoice[0].bankAccountNumber;
         *
         *          _payment = new DA_Payment(_database).createPayment(_payment);
         *
         *          new DA_Bank(_database).updateBalanceBankAccountAmountTotal(int.Parse(_beInvoice.invoiceId), _lstVeInvoice[0].bankAccountId);
         *
         *      }
         *
         *  }
         *  if (_lstBeInvoice.Count > 0 && _payment != null && _paymentAuth != null)
         *          return _lstBeInvoice;
         *      else
         *          throw new Exception("Ocurrió un error al realizar la transacción");
         *
         *
         * }*/

        public List <BE_Invoice> MakePayments(List <VE_Invoice> _lstVeInvoice)
        {
            _database = new MySQLDatabase(connectionString);
            if (_lstVeInvoice.Count == 0)
            {
                throw new Exception("La lista enviada no contiene elementos");
            }

            List <BE_Invoice> _lstBeInvoice = new List <BE_Invoice>();

            List <BE_PaymentAuth> _lstPaymentAuth    = new List <BE_PaymentAuth>();
            List <BE_PaymentAuth> _lstPaymentAuthAux = new List <BE_PaymentAuth>();
            BE_Payment            _payment           = new BE_Payment();
            BE_PaymentAuthDetail  _paymentAuthDetail = new BE_PaymentAuthDetail();
            BL_WorkFlow           _blWorkFlow        = new BL_WorkFlow();
            BL_Usuario            bL_Usuario         = new BL_Usuario();

            bL_Usuario.connectionString = connectionString;
            List <BE_User> bE_Users = new List <BE_User>();

            foreach (VE_Invoice _veInvoice in _lstVeInvoice)
            {
                _lstBeInvoice.AddRange(new DA_Invoice(_database).getInvoiceToPayBySum(_veInvoice));
                bE_Users.AddRange(bL_Usuario.GetUserGeneral(new BE_UserFilter {
                    id = _veInvoice.userId
                }));
            }

            if (_lstBeInvoice.Count > 0)
            {
                foreach (BE_Invoice _beInvoice in _lstBeInvoice)
                {
                    _blWorkFlow = new BL_WorkFlow();
                    _blWorkFlow.connectionString = connectionString;
                    var  mensaje = "";
                    bool bOk     = _blWorkFlow.NextWorkFlowStep(ref mensaje, 2, int.Parse(_beInvoice.invoiceId), bE_Users[0].userName, false);

                    if (!bOk)
                    {
                        throw new Exception(mensaje);
                    }
                }
                foreach (VE_Invoice _veInvoice in _lstVeInvoice)
                {
                    if (_lstPaymentAuth.Count() == 0)
                    {
                        BE_PaymentAuth _PaymentAuth = new BE_PaymentAuth();
                        _PaymentAuth.bankAccountId = _veInvoice.bankAccountId;
                        _PaymentAuth.companyCode   = _veInvoice.companyCode;
                        //_PaymentAuth.userName = _veInvoice.userName;
                        _PaymentAuth.userName     = "";
                        _PaymentAuth.memoryRuc    = _veInvoice.customerRuc;
                        _PaymentAuth.exchangeRate = _veInvoice.exchangeRate == null ? 0 : decimal.Parse(_lstVeInvoice[0].exchangeRate);
                        _lstPaymentAuthAux.Add(_PaymentAuth);
                        _lstPaymentAuth.AddRange(_lstPaymentAuthAux);
                    }
                    else
                    {
                        var cont = 0;
                        foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
                        {
                            cont++;
                            if ((bE_PaymentAuth.bankAccountId != _veInvoice.bankAccountId || !bE_PaymentAuth.memoryRuc.Equals(_veInvoice.customerRuc)) && cont == _lstPaymentAuth.Count())
                            {
                                BE_PaymentAuth _PaymentAuth = new BE_PaymentAuth();
                                _PaymentAuth.bankAccountId = _veInvoice.bankAccountId;
                                _PaymentAuth.companyCode   = _veInvoice.companyCode;
                                //_PaymentAuth.userName = _veInvoice.userName;
                                _PaymentAuth.userName     = "";
                                _PaymentAuth.memoryRuc    = _veInvoice.customerRuc;
                                _PaymentAuth.exchangeRate = _veInvoice.exchangeRate == null ? 0 : decimal.Parse(_lstVeInvoice[0].exchangeRate);
                                _lstPaymentAuthAux.Add(_PaymentAuth);
                            }
                        }
                        _lstPaymentAuth = new List <BE_PaymentAuth>();
                        _lstPaymentAuth.AddRange(_lstPaymentAuthAux);
                    }
                }


                _lstPaymentAuthAux = new List <BE_PaymentAuth>();
                foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
                {
                    var aux = new DA_Payment(_database).createPaymentAuth(bE_PaymentAuth);

                    _lstPaymentAuthAux.Add(aux);
                }
                _lstPaymentAuth = new List <BE_PaymentAuth>();
                _lstPaymentAuth.AddRange(_lstPaymentAuthAux);

                foreach (BE_Invoice _beInvoice in _lstBeInvoice)
                {
                    foreach (BE_PaymentAuth bE_PaymentAuth in _lstPaymentAuth)
                    {
                        if (bE_PaymentAuth.bankAccountId == _beInvoice.bankAccountId)
                        {
                            _beInvoice.bankId            = _lstVeInvoice[0].bankId;
                            _beInvoice.bankAccountId     = _lstVeInvoice[0].bankAccountId;
                            _beInvoice.bankAccountNumber = _lstVeInvoice[0].bankAccountNumber;
                            new DA_Invoice(_database).payInvovice(_beInvoice);

                            _payment = new BE_Payment();
                            _payment.paymentAuthId     = bE_PaymentAuth.paymentAuthId;
                            _payment.id                = _beInvoice.invoiceId;
                            _payment.bankId            = _lstVeInvoice[0].bankId;
                            _payment.bankAccountId     = _lstVeInvoice[0].bankAccountId;
                            _payment.bankAccountNumber = _lstVeInvoice[0].bankAccountNumber;

                            _payment = new DA_Payment(_database).createPayment(_payment);



                            new DA_Bank(_database).updateBalanceBankAccountByInvoice(int.Parse(_beInvoice.invoiceId), _lstVeInvoice[0].bankAccountId);

                            _paymentAuthDetail = new BE_PaymentAuthDetail();
                            _paymentAuthDetail.paymentAuthId = bE_PaymentAuth.paymentAuthId;
                            //_paymentAuthDetail.userAudit = _veInvoice.userName;
                            _paymentAuthDetail.userAudit = "";
                            _paymentAuthDetail           = new DA_Payment(_database).createFirstPAD(_paymentAuthDetail);
                        }
                    }
                }
            }
            if (_lstBeInvoice.Count > 0 && _payment != null && _lstPaymentAuth != null)
            {
                return(_lstBeInvoice);
            }
            else
            {
                throw new Exception("Ocurrió un error al realizar la transacción");
            }
        }