public ReportClass GetListReport(OutputDeliveryList list,
                                         ClienteList clientes)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            OutputDeliveryListRpt doc = new OutputDeliveryListRpt();

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

            foreach (OutputDeliveryInfo item in list)
            {
                pList.Add(OutputDeliveryPrint.New(item,
                                                  clientes.GetItem(item.OidHolder),
                                                  null));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
예제 #2
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 InformeCarteraClientesRpt GetCarteraClientesReport(ClienteList lista, SerieInfo serie, FormatConfCarteraClientesReport conf)
        {
            if (lista == null || lista.Count == 0)
            {
                return(null);
            }

            InformeCarteraClientesRpt   doc        = new InformeCarteraClientesRpt();
            List <CarteraClientesPrint> pList      = new List <CarteraClientesPrint>();
            List <CobroFacturaPrint>    pCobroList = new List <CobroFacturaPrint>();

            QueryConditions conditions = new QueryConditions
            {
                Serie    = serie,
                FechaIni = conf.inicio,
                FechaFin = conf.final
            };

            foreach (ClienteInfo item in lista)
            {
                conditions.Cliente = item;

                GetFacturas(item, conditions, conf, pList, pCobroList);
            }

            doc.SetDataSource(pList);
            if (pCobroList.Count != 0)
            {
                doc.Subreports["CobroFacturasRpt"].SetDataSource(pCobroList);
            }
            else
            {
                conf.verCobros = false;
            }

            doc.SetParameterValue("VerCobros", conf.verCobros);

            FormatReport(doc, conf);
            FormatHeader(doc);

            return(doc);
        }
        public ClienteListRpt GetListReport(ClienteList list)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            ClienteListRpt doc = new ClienteListRpt();

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

            foreach (ClienteInfo item in list)
            {
                pList.Add(ClientePrint.New(item));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
예제 #5
0
        public ReportClass GetListReport(BudgetList list, ClienteList clientes, SerieList series)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            BudgetListRpt doc = new BudgetListRpt();

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

            foreach (BudgetInfo item in list)
            {
                pList.Add(item.GetPrintObject((clientes == null) ? null : clientes.GetItem(item.OidCliente),
                                              series.GetItem(item.OidSerie)));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            return(doc);
        }
        public ReportClass GetDetailListReport(OutputDeliveryList list,
                                               ClienteList clientes,
                                               ETipoAlbaranes tipo,
                                               DateTime fini,
                                               DateTime ffin)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            AlbaranDetailListRpt doc = new AlbaranDetailListRpt();

            List <OutputDeliveryPrint>     pList     = new List <OutputDeliveryPrint>();
            List <OutputDeliveryLinePrint> conceptos = new List <OutputDeliveryLinePrint>();

            foreach (OutputDeliveryInfo item in list)
            {
                pList.Add(OutputDeliveryPrint.New(item,
                                                  clientes.GetItem(item.OidHolder),
                                                  null));

                foreach (OutputDeliveryLineInfo cp in item.Conceptos)
                {
                    conceptos.Add(OutputDeliveryLinePrint.New(cp));
                }
            }

            doc.SetDataSource(pList);
            doc.Subreports["Conceptos"].SetDataSource(conceptos);
            doc.SetParameterValue("Empresa", Schema.Name);
            doc.SetParameterValue("Tipo", tipo.ToString());
            doc.SetParameterValue("FIni", fini);
            doc.SetParameterValue("FFin", ffin);

            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 { }
        }
        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();
                }
            }
        }