public static OutputInvoiceList GetFacturasPendientes()
        {
            DateTime          f_fin = DateTime.Today.AddDays((double)Library.Invoice.ModulePrincipal.GetNotifyPlazoFacturasEmitidas());
            OutputInvoiceList list  = OutputInvoiceList.GetNoCobradasList(DateTime.MinValue, f_fin, false);

            return(list);
        }
示例#2
0
        public ReportClass GetListReport(OutputInvoiceList list, SerieList series)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            OutputInvoiceListRpt doc = new OutputInvoiceListRpt();

            List <OutputInvoicePrint> pList = new List <OutputInvoicePrint>();

            foreach (OutputInvoiceInfo item in list)
            {
                pList.Add(OutputInvoicePrint.New(item,
                                                 null,
                                                 null,
                                                 series.GetItem(item.OidSerie),
                                                 false));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
示例#3
0
        protected void CopyValues(ClienteInfo source)
        {
            if (source == null)
            {
                return;
            }

            Oid = source.Oid;
            _base.CopyValues(source);

            _total_facturado = 0.0m;

            OutputInvoiceList facturas = OutputInvoiceList.GetByClienteList(source, false);

            foreach (OutputInvoiceInfo f in facturas)
            {
                _total_facturado += f.Total;
            }

            _total_cobrado          = 0;
            _efectos_negociados     = 0;
            _efectos_devueltos      = 0;
            _efectos_pendientes_vto = 0;
            _gastos_demora          = 0;
            _gastos_cobro           = 0;
            _condiciones_venta      = 0;

            if (source.Cobros != null)
            {
                foreach (ChargeInfo cobro in source.Cobros)
                {
                    if (cobro.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    if (cobro.EEstadoCobro == EEstado.Charged && cobro.Vencimiento < DateTime.Now)
                    {
                        _total_cobrado += cobro.Importe;
                    }
                    else if (cobro.EEstadoCobro == EEstado.Charged && cobro.Vencimiento >= DateTime.Now)
                    {
                        _efectos_negociados += cobro.Importe;
                    }
                    else if (cobro.EEstadoCobro != EEstado.Charged && cobro.Vencimiento >= DateTime.Now)
                    {
                        _efectos_pendientes_vto += cobro.Importe;
                    }
                    else if (cobro.EEstadoCobro != EEstado.Charged && cobro.Vencimiento < DateTime.Now)
                    {
                        _efectos_devueltos += cobro.Importe;
                    }

                    _gastos_demora += cobro.GastosDemora;
                }

                _base._credito_dispuesto = _total_facturado - _total_cobrado;
            }
        }
示例#4
0
        public static BalanceInfo Get()
        {
            BalanceInfo obj = new BalanceInfo();

            obj._pendientes_pago = PaymentSummaryList.SortList(PaymentSummaryList.GetPendientesList(), "Nombre", ListSortDirection.Ascending);

            Library.Store.QueryConditions conditions = new Library.Store.QueryConditions
            {
                TipoExpediente = ETipoExpediente.Todos,
                Estado         = EEstado.Pendiente
            };

            ExpedienteREAList expedientes = ExpedienteREAList.GetListByREA(conditions, false);

            foreach (ExpedienteREAInfo item in expedientes)
            {
                obj._pendiente_rea += item.AyudaPendiente;
            }

            OutputInvoiceList facturas = OutputInvoiceList.GetNoCobradasList(false);

            obj._pendiente_clientes          = facturas.TotalPendiente();
            obj._efectos_pte_vto_clientes    = facturas.TotalPendienteVencimiento();
            obj._efectos_negociados_clientes = facturas.TotalNegociado();
            obj._efectos_devueltos_clientes  = facturas.TotalDevuelto();

            InventarioValoradoList inventario = InventarioValoradoList.GetListStock(ETipoExpediente.Todos, null, DateTime.Today);

            foreach (InventarioValoradoInfo item in inventario)
            {
                switch (item.TipoExpediente)
                {
                case (long)(ETipoExpediente.Alimentacion):
                    obj._stock_alimentacion_valorado += item.PVP;
                    break;

                case (long)(ETipoExpediente.Ganado):
                    obj._stock_ganado_valorado += item.PVP;
                    break;

                case (long)(ETipoExpediente.Maquinaria):
                    obj._stock_maquinaria_valorado += item.PVP;
                    break;
                }
            }

            obj._saldo_caja = CashInfo.Get(1, true).SaldoTotal;

            return(obj);
        }
示例#5
0
        public new static IAgenteHipatiaList GetAgentes(EntidadInfo entidad)
        {
            IAgenteHipatiaList lista = new IAgenteHipatiaList(new List <IAgenteHipatia>());

            if (entidad.Tipo == typeof(Cliente).Name)
            {
                ClienteList list = ClienteList.GetList(false);

                foreach (ClienteInfo obj in list)
                {
                    if (entidad.Agentes.GetItemByProperty("Oid", obj.Oid) == null)
                    {
                        lista.Add(obj);
                    }
                }
            }
            else if (entidad.Tipo == typeof(Charge).Name)
            {
                ChargeList list = ChargeList.GetList(false);

                foreach (ChargeInfo obj in list)
                {
                    if (entidad.Agentes.GetItemByProperty("Oid", obj.Oid) == null)
                    {
                        lista.Add(obj);
                    }
                }
            }
            else if (entidad.Tipo == typeof(OutputInvoice).Name)
            {
                OutputInvoiceList list = OutputInvoiceList.GetList(false);

                foreach (OutputInvoiceInfo obj in list)
                {
                    if (entidad.Agentes.GetItemByProperty("Oid", obj.Oid) == null)
                    {
                        lista.Add(obj);
                    }
                }
            }
            else
            {
                throw new iQException("No se ha encontrado el tipo de entidad " + entidad.Tipo);
            }

            return(lista);
        }
        public InformeCobrosRpt GetInformeCobrosReport(CobroFacturaList list, OutputInvoiceList facturas)
        {
            InformeCobrosRpt doc = new InformeCobrosRpt();

            List <CobroFacturaPrint> pList = new List <CobroFacturaPrint>();

            foreach (CobroFacturaInfo item in list)
            {
                pList.Add(CobroFacturaPrint.New(item, null, facturas.GetItem(item.OidFactura)));
            }

            if (pList.Count == 0)
            {
                return(null);
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
示例#7
0
        public ReportClass GetBenefitsReport(OutputInvoiceList list)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            InformeBeneficioFacturaRpt doc = new InformeBeneficioFacturaRpt();

            List <OutputInvoicePrint> pList = new List <OutputInvoicePrint>();

            foreach (OutputInvoiceInfo item in list)
            {
                pList.Add(OutputInvoicePrint.New(item, null, null, null, false));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
        public static void SendMailsFacturasPendientes()
        {
            try
            {
                OutputInvoiceList facturas = OutputInvoiceList.GetNoCobradasList(true);
                ClienteList       clientes = ClienteList.GetList(false);
                SerieList         series   = SerieList.GetList(false);
                CompanyInfo       empresa  = CompanyInfo.Get(AppContext.ActiveSchema.Oid);

                SerieInfo   serie;
                ClienteInfo cliente;

                Registro registro = Registro.New(ETipoRegistro.Email);
                registro.Nombre        = "Envio automático de Facturas";
                registro.Observaciones = "Envio automático de Facturas pendientes de pago";

                foreach (OutputInvoiceInfo item in facturas)
                {
                    if (item.Prevision.AddDays(ModulePrincipal.GetPeriodicidadEnvioFacturasPendientes()) > DateTime.Today)
                    {
                        continue;
                    }

                    cliente = clientes.GetItem(item.OidCliente);
                    if (!cliente.EnviarFacturaPendiente)
                    {
                        continue;
                    }

                    serie = series.GetItem(item.OidSerie);

                    FormatConfFacturaAlbaranReport conf = new FormatConfFacturaAlbaranReport();

                    conf.nota  = (cliente.OidImpuesto == 1) ? Resources.Messages.NOTA_EXENTO_IGIC : string.Empty;
                    conf.nota += Environment.NewLine + (item.Nota ? serie.Cabecera : "");

                    OutputInvoiceReportMng reportMng = new OutputInvoiceReportMng(AppContext.ActiveSchema, string.Empty, string.Empty);
                    ReportClass            report    = reportMng.GetDetailReport(item, serie, cliente, null, conf);

                    if (report != null)
                    {
                        LineaRegistro linea = registro.LineaRegistros.NewItem(registro, cliente);

                        ExportOptions options = new ExportOptions();
                        DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();

                        string fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        fileName += "\\" + item.FileName;

                        diskFileDestinationOptions.DiskFileName = fileName;
                        options.ExportFormatType         = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        options.ExportDestinationType    = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                        options.ExportDestinationOptions = diskFileDestinationOptions;

                        report.Export(options);

                        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                        mail.To.Add(new MailAddress(cliente.Email, cliente.Nombre));
                        mail.From    = new MailAddress(SettingsMng.Instance.GetSMTPMail(), empresa.Name);
                        mail.Body    = String.Format(Resources.Messages.FACTURA_EMAIL_ATTACHMENT_BODY, empresa.Name);
                        mail.Subject = Resources.Messages.FACTURA_EMAIL_SUBJECT;
                        mail.Attachments.Add(new Attachment(fileName));

                        try
                        {
                            Thread mailThread = new Thread(SendMailDelegate);
                            mailThread.Start(mail);
                            while (mailThread.IsAlive)
                            {
                                ;
                            }

                            linea.Observaciones = linea.Descripcion;
                            linea.Descripcion   = String.Format(Resources.Messages.FACTURA_EMAIL_OK, item.NFactura);
                        }
                        catch (Exception ex)
                        {
                            linea.Observaciones = linea.Descripcion;
                            linea.Descripcion   = String.Format(Resources.Messages.FACTURA_EMAIL_ERROR, item.NFactura);
                            registro.Save();
                            throw new iQException(ex.Message + Environment.NewLine + Environment.NewLine + moleQule.Library.Resources.Errors.SMTP_SETTINGS);
                        }
                        finally
                        {
                            mail.Dispose();
                            try { File.Delete(fileName); }
                            catch (Exception ex) { string a = ex.Message; }
                        }
                    }
                }

                registro.Save();

                ModulePrincipal.SetFechaUltimoEnvioFacturasPendientes(DateTime.Now);
                AppContext.Principal.SaveSettings();
            }
            catch { }
        }
        private void GetFacturas(ClienteInfo cliente,
                                 QueryConditions conditions,
                                 FormatConfCarteraClientesReport conf,
                                 List <CarteraClientesPrint> pList,
                                 List <CobroFacturaPrint> pCobroList)
        {
            OutputInvoiceList facturas;

            conditions.Cliente = cliente;

            switch (conf.tipo)
            {
            case ETipoFacturas.Cobradas:
            {
                facturas = OutputInvoiceList.GetCobradasList(conditions, false);

                if (facturas.Count > 0)
                {
                    foreach (OutputInvoiceInfo f in facturas)
                    {
                        f.LoadChilds(typeof(CobroFacturaInfo), false);

                        pList.Add(cliente.GetCarteraPrintObject(f));

                        foreach (CobroFacturaInfo cobro in f.CobroFacturas)
                        {
                            pCobroList.Add(CobroFacturaPrint.New(cobro));
                        }
                    }
                }
            } break;

            case ETipoFacturas.Pendientes:
            {
                facturas = OutputInvoiceList.GetNoCobradasList(conditions, false);

                if (facturas.Count > 0)
                {
                    foreach (OutputInvoiceInfo f in facturas)
                    {
                        f.LoadChilds(typeof(CobroFacturaInfo), false);

                        pList.Add(cliente.GetCarteraPrintObject(f));

                        foreach (CobroFacturaInfo cobro in f.CobroFacturas)
                        {
                            pCobroList.Add(CobroFacturaPrint.New(cobro));
                        }
                    }
                }
            }
            break;

            case ETipoFacturas.Todas:
            {
                facturas = OutputInvoiceList.GetList(conditions, false);

                if (facturas.Count == 0)
                {
                    pList.Add(cliente.GetCarteraPrintObject(null));
                }
                else
                {
                    foreach (OutputInvoiceInfo f in facturas)
                    {
                        f.LoadChilds(typeof(CobroFacturaInfo), false);

                        if (f.CobroFacturas.Count > 0)
                        {
                            pList.Add(cliente.GetCarteraPrintObject(f));

                            foreach (CobroFacturaInfo cobro in f.CobroFacturas)
                            {
                                pCobroList.Add(CobroFacturaPrint.New(cobro));
                            }
                        }
                        else
                        {
                            pList.Add(cliente.GetCarteraPrintObject(f));
                        }
                    }
                }
            }
            break;
            }
        }
        public virtual void ExportCharges()
        {
            Charges charges2 = null;

            try
            {
                _invoice_conditions.Orders.Clear();
                _invoice_conditions.Orders.NewOrder("Vencimiento", System.ComponentModel.ListSortDirection.Ascending, typeof(Charge));

                ChargeList cobros = ChargeList.GetList(_invoice_conditions, true);
                //Hacen falta todas porque un cobro puede estar asociado a una factura que no este en las condiciones del filtro
                _invoices = OutputInvoiceList.GetList(false);
                _clients  = (_clients == null) ? ClienteList.GetList(false) : _clients;

                _expedients = ExpedienteList.GetList(false);

                foreach (ChargeInfo item in cobros)
                {
                    if (item.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    LineaRegistro lr = _registry.LineaRegistros.NewItem(_registry, item);

                    switch (item.ETipoCobro)
                    {
                    case ETipoCobro.Cliente:
                    {
                        BuildChargeAccountingEntry(item, lr);
                        BuildFinalcialCashBookChargeAccountingEntry(item);
                    }
                    break;

                    case ETipoCobro.REA:
                    {
                        BuildREAChargeAccountingEntry(item, lr);
                    }
                    break;
                    }

                    _accounting_entry++;
                }

                //Cambiamos el estado de las cobros contabilizados
                charges2 = Charges.GetList(_invoice_conditions, false);
                FinancialCashList efectos = FinancialCashList.GetList(false);

                foreach (Charge item in charges2)
                {
                    if (item.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    if (item.EEstado != EEstado.Exportado)
                    {
                        if (item.EEstadoCobro == EEstado.Charged)
                        {
                            if (item.EMedioPago != EMedioPago.Cheque &&
                                item.EMedioPago != EMedioPago.Pagare)
                            {
                                item.EEstado = EEstado.Exportado;
                            }
                            else
                            {
                                FinancialCashInfo efecto = efectos.GetItemByCobro(item.Oid);
                                if (efecto != null && efecto.EEstadoCobro == EEstado.Charged)
                                {
                                    item.EEstado = EEstado.Exportado;
                                }
                            }
                        }
                    }
                }

                charges2.Save();
            }
            catch (iQException ex)
            {
                _registry = null;
                throw ex;
            }
            catch (Exception ex)
            {
                _registry = null;
                throw ex;
            }
            finally
            {
                if (charges2 != null)
                {
                    charges2.CloseSession();
                }
            }
        }
        public virtual void ExportOutputInvoices()
        {
            OutputInvoices invoices = null;

            try
            {
                _invoice_conditions.Orders.Clear();
                _invoice_conditions.Orders.NewOrder("Fecha", System.ComponentModel.ListSortDirection.Ascending, typeof(OutputInvoice));

                _invoices = OutputInvoiceList.GetList(_invoice_conditions, true);
                _clients  = (_clients == null) ? ClienteList.GetList(false) : _clients;

                foreach (OutputInvoiceInfo item in _invoices)
                {
                    if (item.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    LineaRegistro lr = _registry.LineaRegistros.NewItem(_registry, item);

                    BuildOutputInvoiceAccountingEntry(item, lr);
                    BuildTaxBookRepercutidoAccountingEntry(item);

                    _accounting_entry++;
                }

                //Cambiamos el estado de las facturas contabilizadas
                invoices = OutputInvoices.GetList(_invoice_conditions, false);

                foreach (OutputInvoice item in invoices)
                {
                    if (item.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    if (item.EEstado != EEstado.Exportado)
                    {
                        item.EEstado = EEstado.Exportado;
                    }
                }

                invoices.Save();
            }
            catch (iQException ex)
            {
                _registry = null;
                throw ex;
            }
            catch (Exception ex)
            {
                _registry = null;
                throw ex;
            }
            finally
            {
                if (invoices != null)
                {
                    invoices.CloseSession();
                }
            }
        }