public static void CheckDBVersion() { ApplicationSettingInfo dbVersion = ApplicationSettingInfo.Get(Settings.Default.DB_VERSION_VARIABLE); //Version de base de datos equivalente o no existe la variable if ((dbVersion.Value == string.Empty) || (String.CompareOrdinal(dbVersion.Value, ModulePrincipal.GetDBVersion()) == 0)) { return; } //Version de base de datos superior else if (String.CompareOrdinal(dbVersion.Value, ModulePrincipal.GetDBVersion()) > 0) { throw new iQException(String.Format(Library.Resources.Messages.DB_VERSION_HIGHER, dbVersion.Value, ModulePrincipal.GetDBVersion(), Settings.Default.NAME), iQExceptionCode.DB_VERSION_MISSMATCH); } //Version de base de datos inferior else if (String.CompareOrdinal(dbVersion.Value, ModulePrincipal.GetDBVersion()) < 0) { throw new iQException(String.Format(Library.Resources.Messages.DB_VERSION_LOWER, dbVersion.Value, ModulePrincipal.GetDBVersion(), Settings.Default.NAME), iQExceptionCode.DB_VERSION_MISSMATCH); } }
public void AutoPilot() { DateTime f_envio = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy") + " " + ModulePrincipal.GetHoraEnvioFacturasPendientes().ToString("HH:mm"), CultureInfo.CreateSpecificCulture("es-ES")); if (DateTime.Now < f_envio) { return; } if (ModulePrincipal.GetSendFacturasPendientes() && (ModulePrincipal.GetFechaUltimoEnvioFacturasPendientes().AddDays(ModulePrincipal.GetPlazoEnvioFacturasPendientes()) < DateTime.Today)) { Thread thread = new Thread(SendMailsFacturasPendientes); thread.Start(); } }
internal static Decimal GetPrecioCliente(ProductoClienteInfo productoCliente, BatchInfo partida, ProductInfo producto, ETipoFacturacion tipo) { Decimal precio = 0; ETipoFacturacion tipoFacturacion = tipo; if (productoCliente != null) { precio = (productoCliente.ETipoDescuento == Common.ETipoDescuento.Precio) ? productoCliente.Precio : producto.PrecioVenta; tipoFacturacion = productoCliente.ETipoFacturacion; } else { precio = producto.PrecioVenta; tipoFacturacion = producto.ETipoFacturacion; } Decimal kilosBulto = (partida != null) ? partida.KilosPorBulto : producto.KilosBulto; kilosBulto = (kilosBulto == 0) ? 1 : kilosBulto; switch (tipo) { case ETipoFacturacion.Peso: if (tipoFacturacion != ETipoFacturacion.Peso) { precio = precio * kilosBulto; } break; default: if (tipoFacturacion == ETipoFacturacion.Peso) { precio = precio / kilosBulto; } break; } return(Decimal.Round(precio, ModulePrincipal.GetNDecimalesPreciosSetting())); }
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 static void UpgradeSettings() { ModulePrincipal.UpgradeSettings(); }
/// <summary> /// Crea los conceptos de factura asociados a un albarán /// </summary> /// <param name="source"></param> public virtual void Compact(OutputInvoice invoice) { if (this.Count == 0) { return; } OutputDelivery main_albaran = null; Cash caja = null; try { List <long> oid_list = new List <long>(); foreach (AlbaranFactura item in this) { oid_list.Add(item.OidAlbaran); } OutputDeliveryList albaranes = OutputDeliveryList.GetList(oid_list, true); main_albaran = OutputDelivery.Get(oid_list[0], true, invoice.SessionCode); foreach (AlbaranFactura af in this) { if (af.OidAlbaran == main_albaran.Oid) { continue; } OutputDeliveryInfo source = albaranes.GetItem(af.OidAlbaran); main_albaran.Merge(source); } main_albaran.Compact(); SortedBindingList <AlbaranFactura> sorted_list = this.GetSortedList("CodigoAlbaran", ListSortDirection.Ascending); OutputDeliveryInfo first_albaran = OutputDeliveryInfo.Get(sorted_list[0].OidAlbaran, ETipoEntidad.Cliente, false); main_albaran.CopyFrom(invoice); main_albaran.Codigo = first_albaran.Codigo; main_albaran.Serial = first_albaran.Serial; main_albaran.Save(); ToDelete = new List <OutputDeliveryInfo>(); for (int i = 1; i < oid_list.Count; i++) { Remove(GetItemByAlbaran(oid_list[i]).Oid); ToDelete.Add(albaranes.GetItem(oid_list[i])); } CashLine.DeleteByAlbaranList(albaranes.GetListInfo(), ModulePrincipal.GetCajaTicketsSetting()); Ticket.DeleteFromList(albaranes.GetListInfo()); //Actualizamos la caja de Tickets caja = Cash.Get(ModulePrincipal.GetCajaTicketsSetting(), true, invoice.SessionCode); caja.UpdateSaldo(); caja.SaveAsChild(); AlbaranFactura ab = GetItemByAlbaran(main_albaran.Oid); ab.CodigoAlbaran = main_albaran.Codigo; } catch (Exception ex) { throw ex; } finally { Cache.Instance.Remove(typeof(ClienteList)); Cache.Instance.Remove(typeof(ProductList)); } }