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); }
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 { } }
protected string GetChargeAccount(ChargeInfo charge) { string cuenta = string.Empty; string info = string.Empty; try { switch (charge.EMedioPago) { case EMedioPago.Efectivo: CashInfo caja = CashInfo.Get(1); cuenta = caja.CuentaContable; info = String.Format(Resources.Messages.CASH_BOOK_ACCOUNT_NOT_FOUND, caja.Codigo, caja.Nombre); break; case EMedioPago.Tarjeta: if (Invoice.ModulePrincipal.GetUseTPVCountSetting()) { TPVInfo tpv = TPVInfo.Get(charge.OidTPV); cuenta = tpv.CuentaContable; info = tpv.Nombre; info = String.Format(Resources.Messages.TPV_BOOK_ACCOUNT_NOT_FOUND, tpv.Nombre); } else { BankAccountInfo cb = _bank_accounts.GetItem(charge.OidCuentaBancaria); cuenta = cb.CuentaContable; info = String.Format(Resources.Messages.BANK_ACCOUNT_BOOK_ACCOUNT_NOT_FOUND, cb.Valor, cb.Entidad); } break; case EMedioPago.CompensacionFactura: ClienteInfo client = _clients.GetItem(charge.OidCliente); cuenta = client.CuentaContable; info = String.Format(Resources.Messages.CLIENT_BOOK_ACCOUNT_NOT_FOUND, client.Codigo, client.Nombre); break; case EMedioPago.Pagare: case EMedioPago.Cheque: { FinancialCashInfo efecto = FinancialCashInfo.GetByCobro(charge, false); if (efecto.EEstadoCobro == EEstado.Charged) { BankAccountInfo cb = _bank_accounts.GetItem(efecto.OidCuentaBancaria); cuenta = cb.CuentaContable; info = String.Format(Resources.Messages.BANK_ACCOUNT_BOOK_ACCOUNT_NOT_FOUND, cb.Valor, cb.Entidad); } else { cuenta = GetFinancialCashChargesAccount(efecto.Vencimiento); } } break; default: { BankAccountInfo cb = _bank_accounts.GetItem(charge.OidCuentaBancaria); cuenta = cb.CuentaContable; info = String.Format(Resources.Messages.BANK_ACCOUNT_BOOK_ACCOUNT_NOT_FOUND, cb.Valor, cb.Entidad); } break; } } catch (Exception ex) { if (ex is iQException) { throw ex; } else { throw new iQException("El cobro nº " + charge.Codigo + " no tiene cuenta bancaria asociada"); } } if (cuenta == string.Empty) { throw new iQException(info); } return(cuenta); }