Пример #1
0
        public List <VE_Invoice> GetBankAdjusmentHistory(int bankAccountId)
        {
            VE_Invoice                  _VeInvoice  = null;
            List <VE_Invoice>           _lstInvoice = new List <VE_Invoice>();
            Dictionary <string, object> parameters  = new Dictionary <string, object>();


            parameters.Add("_bankAccountId", bankAccountId);


            var rows = _database.QuerySP("sp_getBankAdjusmentHistory", parameters);

            foreach (var row in rows)
            {
                _VeInvoice                               = new VE_Invoice();
                _VeInvoice.invoiceId                     = row["Id"];
                _VeInvoice.amountBalance                 = string.IsNullOrEmpty(row["AmountBalance"]) ? 0 : decimal.Parse(row["AmountBalance"]);
                _VeInvoice.amountDetraction              = string.IsNullOrEmpty(row["AmountDetraction"]) ? 0 : decimal.Parse(row["AmountDetraction"]);
                _VeInvoice.amountPayment                 = string.IsNullOrEmpty(row["AmountPayment"]) ? 0 : decimal.Parse(row["AmountPayment"]);
                _VeInvoice.amountPaymentDetraction       = string.IsNullOrEmpty(row["AmountPaymentDetraction"]) ? 0 : decimal.Parse(row["AmountPaymentDetraction"]);
                _VeInvoice.amountPaymentFromBank         = string.IsNullOrEmpty(row["AmountPaymentFromBank"]) ? 0 : decimal.Parse(row["AmountPaymentFromBank"]);
                _VeInvoice.amountPaymentPen              = string.IsNullOrEmpty(row["AmountPaymentPen"]) ? 0 : decimal.Parse(row["AmountPaymentPen"]);
                _VeInvoice.amountTotal                   = string.IsNullOrEmpty(row["AmountTotal"]) ? 0 : decimal.Parse(row["AmountTotal"]);
                _VeInvoice.bankAccountId                 = string.IsNullOrEmpty(row["BankAccountId"]) ? 0 : int.Parse(row["BankAccountId"]);
                _VeInvoice.bankAccountNumber             = row["BankAccountNumber"];
                _VeInvoice.bankId                        = string.IsNullOrEmpty(row["BankId"]) ? 0 : int.Parse(row["BankId"]);
                _VeInvoice.budgetFile                    = row["BudgetFile"];
                _VeInvoice.companyCode                   = row["CompanyCode"];
                _VeInvoice.currency                      = row["Currency"];
                _VeInvoice.currencyPayment               = row["CurrencyPayment"];
                _VeInvoice.customerBankAccountPen        = row["CustomerBankAccountPen"];
                _VeInvoice.customerBankAccountUsd        = row["CustomerBankAccountUsd"];
                _VeInvoice.customerName                  = row["CustomerName"];
                _VeInvoice.customerRuc                   = row["CustomerRuc"];
                _VeInvoice.documentDate                  = string.IsNullOrEmpty(row["DocumentDate"]) ? DateTime.Now : DateTime.Parse(row["DocumentDate"]);
                _VeInvoice.documentId                    = row["DocumentId"];
                _VeInvoice.dueDate                       = string.IsNullOrEmpty(row["DueDate"]) ? DateTime.Now : DateTime.Parse(row["DueDate"]);
                _VeInvoice.exchangeRate                  = row["ExchangeRate"];
                _VeInvoice.invoiceFile                   = row["InvoiceFile"];
                _VeInvoice.ocrFile                       = row["OCRFile"];
                _VeInvoice.customerEmail                 = row["CustomerEmail"];
                _VeInvoice.documentType                  = row["DocumentType"];
                _VeInvoice.customerBankAccountDetraction = row["CustomerBankAccountDetraction"];
                _VeInvoice.nroComprobante                = row["NroComprobante"];
                _VeInvoice.nroSerie                      = row["NroSerie"];
                _VeInvoice.tipoServicio                  = row["TipoServicio"];
                _VeInvoice.customerDocType               = row["CustomerDocType"];
                _VeInvoice.accounting                    = row["Accounting"];
                _VeInvoice.amountDetraccionUS            = string.IsNullOrEmpty(row["AmountDetractionUS"]) ? 0 : decimal.Parse(row["AmountDetractionUS"]);
                _VeInvoice.status                        = row["Status"];
                _VeInvoice.invoiceStatusId               = string.IsNullOrEmpty(row["InvoiceStatusId"]) ? 0 : int.Parse(row["InvoiceStatusId"]);
                _VeInvoice.invoiceType                   = row["InvoiceType"];
                _VeInvoice.reference                     = row["reference"];
                _VeInvoice.comments                      = row["comments"];
                _lstInvoice.Add(_VeInvoice);
            }


            return(_lstInvoice);
        }
Пример #2
0
        public BE_Json GetInvoiceExpByCompany(string companyCode, string searchField)
        {
            //BL_Invoice _blInvoice = new BL_Invoice();
            //_blInvoice.connectionString = AppConfig.DbConnection;
            //return _blInvoice.GetInvoiceById(_invoiceId);

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

            try
            {
                BL_Invoice _blInvoice = new BL_Invoice();
                _blInvoice.connectionString = AppConfig.DbConnection;
                List <VE_Invoice> a = new List <VE_Invoice>();
                VE_Invoice        b = new VE_Invoice();
                a.Add(b);
                objListaAux = JsonConvert.SerializeObject(a);

                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);
        }
Пример #3
0
        public BE_Json DeleteInvoice(VE_Invoice _VeInvoice)
        {
            //BL_Invoice _blInvoice = new BL_Invoice();
            //_blInvoice.connectionString = AppConfig.DbConnection;
            //return _blInvoice.DeleteInvoice(_VeInvoice);

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

            try
            {
                BL_Invoice _blInvoice = new BL_Invoice();
                _blInvoice.connectionString = AppConfig.DbConnection;
                objListaAux = JsonConvert.SerializeObject(_blInvoice.DeleteInvoice(_VeInvoice));

                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);
        }
Пример #4
0
        public BE_Json BankAdjustment([FromBody] VE_Invoice vE_Invoice)
        {
            BE_Json objJson     = null;
            var     objListaAux = string.Empty;

            try
            {
                BL_Bank _blBank = new BL_Bank();
                _blBank.connectionString = AppConfig.DbConnection;
                objListaAux = JsonConvert.SerializeObject(_blBank.BankAdjustment(vE_Invoice));

                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);
        }
Пример #5
0
        public bool CreateSchedule(BE_Schedule bE_Schedule)
        {
            _database = new MySQLDatabase(connectionString);
            bool       bOk       = true;
            BL_Invoice blInvoice = new BL_Invoice();

            blInvoice.connectionString = connectionString;
            //blInvoice._database = _database;

            VE_Invoice invoice = blInvoice.CreateInvoiceGeneral(bE_Schedule.Invoice);

            bOk = (invoice != null);

            if (exist(bE_Schedule))
            {
                bOk = bOk && new DA_Schedule(_database).UpdateSchedule(bE_Schedule);
            }
            else
            {
                bOk = bOk && new DA_Schedule(_database).CreateSchedule(bE_Schedule);
            }


            return(bOk);
        }
Пример #6
0
        public VE_BankAccount BankAdjustment(VE_Invoice vE_Invoice)
        {
            vE_Invoice.invoiceDetail = new List <VE_InvoiceDetail>();
            if (vE_Invoice.amountTotal < 0)
            {
                vE_Invoice.amountTotal = vE_Invoice.amountTotal * -1;
                vE_Invoice.invoiceType = "O";
            }
            else
            {
                vE_Invoice.invoiceType = "S";
            }
            BL_Invoice bL_Invoice = new BL_Invoice();

            bL_Invoice.connectionString = connectionString;
            var invoice = bL_Invoice.CreateInvoice(vE_Invoice);

            _database = new MySQLDatabase(connectionString);
            return(new DA_Bank(_database).updateBalanceBankAccountByInvoice(int.Parse(invoice.invoiceId), invoice.bankAccountId));
        }
Пример #7
0
        public BE_Json UpdateInvoiceGeneral([FromBody] VE_Invoice _VeInvoice)
        {
            BE_Json objJson     = null;
            var     objListaAux = string.Empty;

            if (_VeInvoice == null)
            {
                return(objJson);
            }

            try
            {
                BL_Invoice _blInvoice = new BL_Invoice();
                _blInvoice.connectionString = AppConfig.DbConnection;
                objListaAux = JsonConvert.SerializeObject(_blInvoice.updateInvoiceGeneral(_VeInvoice));

                objJson        = new BE_Json();
                objJson.data   = objListaAux;
                objJson.status = CManager.RESULTADO_WCF.OK;
            }
            catch (ApplicationException ex)
            {
                objJson        = new BE_Json();
                objJson.data   = ex.Message;
                objJson.status = CManager.RESULTADO_WCF.ERROR;
            }
            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);
        }
Пример #8
0
        /*
         * public VE_Invoice updateInvoiceGeneral(VE_Invoice _vE_Invoice)
         * {
         *  _database = new MySQLDatabase(connectionString);
         *  return new DA_Invoice(_database).updateInvoiceGeneral(_vE_Invoice);
         * }*/

        public VE_Invoice updateInvoiceGeneral(VE_Invoice _VeInvoice)
        {
            _database = new MySQLDatabase(connectionString);

            BL_Option bL_Option = new BL_Option(this.connectionString);
            //bL_Option.connectionString = connectionString;
            var ok = bL_Option.ValidateOption(9, _VeInvoice.userName);

            if (ok == 0)
            {
                throw new ApplicationException("Ud. no cuenta con los permisos necesarios");
            }

            if (_VeInvoice.documentId != null)
            {
                var numbers = _VeInvoice.documentId.Split('-');
                if (numbers.Count() < 2)
                {
                    throw new ApplicationException("Ingrese una factura válida");
                }
                _VeInvoice.nroSerie       = numbers[0];
                _VeInvoice.nroComprobante = numbers[1];
            }


            new DA_Invoice(_database).updateInvoiceGeneral(_VeInvoice);

            var invoice = new DA_Invoice(_database).getInvoiceGeneral(new BEInvoiceFilter {
                invoiceIdList = _VeInvoice.invoiceId
            });

            if (_VeInvoice.invoiceStatusId != invoice[0].invoiceStatusId)
            {
                BL_WorkFlow _blWorkFlow = new BL_WorkFlow();
                _blWorkFlow.connectionString = connectionString;
                var  mensaje = "";
                bool bOk     = false;
                if (_VeInvoice.invoiceStatusId == 2)
                {
                    bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 9, int.Parse(_VeInvoice.invoiceId), _VeInvoice.userName, false);
                }
                else
                {
                    bOk = _blWorkFlow.NextWorkFlowStep(ref mensaje, 1, int.Parse(_VeInvoice.invoiceId), _VeInvoice.userName, false);
                }

                if (!bOk)
                {
                    throw new ApplicationException(mensaje);
                }
            }
            new DA_Invoice(_database).DeleteInvoiceDetailByInvoiceId(_VeInvoice.invoiceId);

            if (_VeInvoice.invoiceDetail != null)
            {
                foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail)
                {
                    _veInvoiceDetail.invoiceId = int.Parse(_VeInvoice.invoiceId);
                    new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail);
                }
            }
            return(_VeInvoice);
        }
Пример #9
0
 public VE_Invoice DeleteInvoice(VE_Invoice _VeInvoice)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Invoice(_database).deleteInvoice(_VeInvoice));
 }
Пример #10
0
 public VE_Invoice UpdateInvoiceStatus(VE_Invoice _VeInvoice)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Invoice(_database).updateInvoiceStatus(_VeInvoice));
 }
Пример #11
0
        public VE_Invoice CreateInvoice(VE_Invoice _VeInvoice)
        {
            string invoiceId;

            _database = new MySQLDatabase(connectionString);

            var companysSystem = (new BL_Company()
            {
                connectionString = connectionString
            }).GetCompanyGeneral(new BECompanyFilter()
            {
                companyCode = _VeInvoice.companyCode
            });

            BE_Company _companySystem = null;

            if (companysSystem.Count > 0)
            {
                _companySystem = companysSystem[0];
            }
            else
            {
                throw new Exception("codigo Invalido");
            }

            if (_VeInvoice.invoiceType.Equals("O") && _companySystem.companyType.Equals("3"))// del sistema
            {
                var companysEmisor = (new BL_Company()
                {
                    connectionString = connectionString
                }).GetCompanyGeneral(new BECompanyFilter()
                {
                    companyRUC = _VeInvoice.customerRuc
                });
                BE_Company _companyEmisor = null;
                if (companysEmisor.Count > 0)
                {
                    _companyEmisor = companysEmisor[0];
                }
                else
                {
                    throw new Exception("codigo Invalido");
                }
                _VeInvoice.companyCode  = _companyEmisor.companyCode;
                _VeInvoice.customerRuc  = _companySystem.companyRUC;
                _VeInvoice.customerName = _companySystem.companyName;
            }

            if (_VeInvoice.documentId != null)
            {
                var numbers = _VeInvoice.documentId.Split('-');
                if (numbers.Count() < 2)
                {
                    throw new Exception("Ingrese una factura válida");
                }
                _VeInvoice.nroSerie       = numbers[0];
                _VeInvoice.nroComprobante = numbers[1];
            }
            invoiceId = new DA_Invoice(_database).createInvoice(_VeInvoice).invoiceId;

            foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail)
            {
                _veInvoiceDetail.invoiceId = int.Parse(invoiceId);
                new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail);
            }



            return(_VeInvoice);
        }
Пример #12
0
        public VE_Invoice CreateInvoiceGeneral(VE_Invoice _VeInvoice)
        {
            string invoiceId;

            _database = new MySQLDatabase(connectionString);

            var companysSystem = (new BL_Company()
            {
                connectionString = connectionString
            }).GetCompanyGeneral(new BECompanyFilter()
            {
                companyCode = _VeInvoice.companyCode
            });

            BE_Company _companySystem = null;

            if (companysSystem.Count > 0)
            {
                _companySystem = companysSystem[0];
            }
            else
            {
                throw new Exception("codigo Invalido");
            }

            if ((_VeInvoice.invoiceType.Equals(BE_Invoice.ORDER) || _VeInvoice.invoiceType.Equals(BE_Invoice.PURCHASEORDER)) && _companySystem.companyType.Equals("3")) // del sistema
            {
                var companysEmisor = (new BL_Company()
                {
                    connectionString = connectionString
                }).GetCompanyGeneral(new BECompanyFilter()
                {
                    companyRUC = _VeInvoice.customerRuc
                });
                BE_Company _companyEmisor = null;
                if (companysEmisor.Count > 0)
                {
                    _companyEmisor = companysEmisor[0];
                }
                else
                {
                    throw new Exception("codigo Invalido");
                }
                _VeInvoice.companyCode  = _companyEmisor.companyCode;
                _VeInvoice.customerRuc  = _companySystem.companyRUC;
                _VeInvoice.customerName = _companySystem.companyName;
            }


            invoiceId = new DA_Invoice(_database).createInvoice(_VeInvoice).invoiceId;

            foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail)
            {
                _veInvoiceDetail.invoiceId = int.Parse(invoiceId);
                new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail);
            }



            return(_VeInvoice);
        }