Пример #1
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");
            }
        }
Пример #2
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");
            }
        }
Пример #3
0
 public bool CreatePaymentDetail(BE_PaymentDetail bE_PaymentDetail)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Payment(_database).CreatePaymentDetail(bE_PaymentDetail));
 }
Пример #4
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");
            }
        }