code
stringlengths
1
1.73M
language
stringclasses
1 value
class CreateBonificaciones < ActiveRecord::Migration def self.up create_table :bonificaciones do |t| t.column :convenio_id, :integer, :null => false t.column :marca_id, :integer, :null => false t.column :porcentaje, :integer, :null => false t.column :destino, :integer, ...
Ruby
#!/opt/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/opt/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/opt/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo...
Ruby
#!/opt/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/opt/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/opt/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VE...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) unless defined?(Rails::Initializer) if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/init...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
module ComodatoHelper end
Ruby
module ListaPrecioHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def logged_in? return true if session[:user] return false end def menu menu_text = "" if logged_in? ejecutivo = Ejecutivo.find(session[:user]) menu_text = ejecutivo.nombre_...
Ruby
module CorporativosHelper end
Ruby
module MovimientoHelper end
Ruby
module Concurso::VentaHelper end
Ruby
module Concurso::PremioHelper def add_dynamic_link link_to_function 'Agregar Premio' do |page| page.insert_html :bottom, :premios, :partial => 'premio', :object => ConcursoPremio.new end end end
Ruby
module Concurso::ObjetivoHelper def add_dynamic_link link_to_function 'Agregar Objetivo' do |page| page.insert_html :bottom, :objetivos, :partial => 'objetivo', :object => ConcursoObjetivo.new end end end
Ruby
module SalidaHelper end
Ruby
module MarcaHelper end
Ruby
module Centro::PersonalHelper end
Ruby
module PromocionHelper end
Ruby
module EmpresaHelper end
Ruby
module CentroHelper end
Ruby
module FamiliaHelper end
Ruby
module AutorizarHelper end
Ruby
module PresenciaHelper end
Ruby
module PresupuestoHelper end
Ruby
module Personal::EjecutivoHelper end
Ruby
module AlmacenHelper end
Ruby
module Salida::ConcursoHelper end
Ruby
module Salida::PromocionHelper end
Ruby
module Salida::BonificacionHelper end
Ruby
module Salida::PresenciaHelper end
Ruby
module Catalogo::EntradasHelper end
Ruby
module FacturaHelper def agregar_detalle(titulo) link_to_function titulo do |page| page.insert_html :bottom, :detalles, :partial => 'detalle', :object => DetalleFactura.new end end end
Ruby
module CategoriaHelper end
Ruby
module CatalogoHelper end
Ruby
module RequisicionHelper end
Ruby
module LoginHelper end
Ruby
module ConvenioHelper end
Ruby
module MayoristaHelper end
Ruby
module MaterialHelper end
Ruby
module Evaluacion::VentaHelper end
Ruby
module Evaluacion::PremioHelper end
Ruby
module Evaluacion::ObjetivoHelper end
Ruby
module ProductoHelper end
Ruby
class BusquedaProductos < ActiveRecord::Base end
Ruby
class PuntajeMesero < ActiveRecord::Base belongs_to :evaluacion belongs_to :empleado CARGO = 2 ABONO = 1 validates_presence_of :operacion, :puntos, :evaluacion_id, :empleado_id validates_numericality_of :puntos end
Ruby
class ApoyoMaterial < ActiveRecord::Base belongs_to :promocion validates_presence_of :material_id validates_numericality_of :costo_unitario, :cantidad def importe unless costo_unitario.blank? && cantidad.blank? costo_unitario * cantidad else 0 end end end
Ruby
class BusquedaConcurso < ActiveRecord::Base def consecutivo "%06d" % id + '/' + fecha_inicio.strftime("%Y") end end
Ruby
class PresupuestoDetalle < ActiveRecord::Base belongs_to :presupuesto INICIAL = 1 ABONO = 2 CARGO = 3 DESCRIPCION = { 1 => 'Inicial', 2 => 'Abono', 3 => 'Cargo' } end
Ruby
class Canje < ActiveRecord::Base belongs_to :evaluacion has_many :canje_detalles validates_presence_of :empleado_id validates_numericality_of :empleado_id end
Ruby
class Familia < ActiveRecord::Base belongs_to :categoria belongs_to :empresa has_many :marcas, :conditions => {:status_id => 1} has_many :productos, :conditions => {:status_id => 1} validates_presence_of :nombre, :categoria_id, :empresa_id validates_numericality_of :categoria_id, :empresa_id def ...
Ruby
class ConcursoPremioMarca < ActiveRecord::Base belongs_to :concurso validates_presence_of :marca_id end
Ruby
class BusquedaFactura < ActiveRecord::Base end
Ruby
class Producto < ActiveRecord::Base belongs_to :marca belongs_to :familia before_save :actualiza_empresa validates_presence_of :descripcion, :sociedad_id, :familia_id, :marca_id, :clave, :presentacion_id validates_uniqueness_of :clave validates_numericality_of :costo_cuervo, :precio_venta, :botell...
Ruby
class ConcursoPremio < ActiveRecord::Base belongs_to :concurso validates_presence_of :lugar, :premio_id end
Ruby
# # To change this template, choose Tools | Templates # and open the template in the editor. require 'pdf/writer' require 'pdf/simpletable' class ConvenioPdf def initialize(convenio_id) @pdf = PDF::Writer.new(:paper => 'LETTER') @convenio = Convenio.find(convenio_id) @pdf.select_font("Times-Roman",...
Ruby
class DetalleFactura < ActiveRecord::Base attr_accessor :should_destroy belongs_to :factura has_one :bonificacion_detalle validates_presence_of :producto_id, :unidades validates_numericality_of :unidades, :only_integer => true def should_destroy? should_destroy.to_i == 1 end end
Ruby
class Presupuesto < ActiveRecord::Base has_many :presupuesto_detalles, :order => 'created_at' has_many :cargos, :class_name => 'PresupuestoDetalle', :conditions => 'operacion = #{PresupuestoDetalle::CARGO}' has_many :abonos, :class_name => 'PresupuestoDetalle', :conditions => 'operacion = #{PresupuestoDetalle::AB...
Ruby
class Presencia < ActiveRecord::Base belongs_to :centro belongs_to :ejecutivo has_many :presencia_exhibiciones has_many :presencia_materiales has_one :solicitud_material validates_presence_of :centro_id, :marca_id, :ejecutivo_id, :descripcion validates_presence_of :nombre def consecutivo "%...
Ruby
class ObjetivoMensual < ActiveRecord::Base belongs_to :convenio validates_presence_of :familia_id, :objetivo_mensual validates_numericality_of :objetivo_mensual, :greater_than => 0, :only_integer => true end
Ruby
class BusquedaOrdenSalida < ActiveRecord::Base def consecutivo "%06d" % id + '/' + created_at.strftime("%Y") end end
Ruby
class BienComodato < ActiveRecord::Base belongs_to :centro validates_presence_of :descripcion_bien, :marca, :modelo, :numero_serie validates_presence_of :comodatario_nombre, :comodatario_cargo def folio "%06d" % id end end
Ruby
class PresenciaMaterial < ActiveRecord::Base belongs_to :presencia validates_presence_of :material_id, :cantidad, :costo_unitario validates_numericality_of :cantidad, :costo_unitario def importe unless cantidad.blank? && costo_unitario.blank? cantidad * costo_unitario else 0 end ...
Ruby
class Catalogo < ActiveRecord::Base validates_presence_of :nombre, :on => :create validates_uniqueness_of :nombre, :on => :create has_many :entradas_catalogo, :order => 'valor' def self.name_value(nombre) Catalogo.find_by_nombre(nombre).entradas_catalogo.each { |e| [e.id, e.valor]} end # encuentra el...
Ruby
class OrdenSalidaDetalle < ActiveRecord::Base belongs_to :orden_salida validates_presence_of :producto_id, :cantidad, :costo_unitario, :precio_ieps validates_presence_of :precio_publico validates_numericality_of :costo_unitario, :precio_ieps, :precio_publico, :cantidad before_save :actualizar_importes ...
Ruby
class Empleado < ActiveRecord::Base belongs_to :centro has_many :puntaje_meseros validates_presence_of :nombre, :primer_apellido, :puesto_id, :on => :create validates_length_of :nombre, :primer_apellido, :maximum => 40, :on => :create def nombre_completo "#{nombre} #{primer_apellido} #{segundo_apellid...
Ruby
class CanjeDetalle < ActiveRecord::Base belongs_to :canje end
Ruby
class SalidaMaterial < ActiveRecord::Base belongs_to :ejecutivo belongs_to :centro has_many :salida_material_detalles validates_presence_of :ejecutivo_id, :centro_id def consecutivo "%06d" % id + '/' + created_at.strftime("%Y") end def detalles_attributes=(detalles_attributes) det...
Ruby
class ApoyoProducto < ActiveRecord::Base belongs_to :promocion validates_presence_of :producto_id, :cantidad validates_numericality_of :cantidad end
Ruby
# # To change this template, choose Tools | Templates # and open the template in the editor. class CalculaBonificacion def initialize end def calcular convenios = convenios_vigentes(Time.now, Convenio::CENTRO_CONSUMO) convenios.each do |convenio| puts "Obteniendo facturas sin procesar para ...
Ruby
class Empresa < ActiveRecord::Base has_many :familias has_many :marcas has_many :productos validates_presence_of :nombre end
Ruby
class Bonificacion < ActiveRecord::Base belongs_to :convenio BOLSA=1 ESPECIE=2 DESTINO = { "Bolsa" => BOLSA, "Especie" => ESPECIE } validates_presence_of :familia_id, :porcentaje, :destino validates_numericality_of :porcentaje end
Ruby
class SalidaMaterialDetalle < ActiveRecord::Base belongs_to :salida_material validates_presence_of :descripcion, :cantidad validates_numericality_of :cantidad, :precio end
Ruby
class Ejecutivo < ActiveRecord::Base has_many :centros, :conditions => {:status_id => 1}, :order => 'nombre_comercial' has_many :corporativos, :conditions => {:status_id => 1} has_many :convenios, :conditions => {:status_id => 1} has_many :presupuestos, :conditions => {:status_id => 1} has_many :concursos, :c...
Ruby
class ConcursoVenta < ActiveRecord::Base belongs_to :concurso before_save :calcula_puntos_botella validates_presence_of :marca_id validates_numericality_of :puntos_copa, :puntos_botella, :allow_nil => true def calcula_puntos_botella self.puntos_botella = self.puntos_copa * DEFAULT_COPAS_BOTELLA ...
Ruby
class Mayorista < ActiveRecord::Base has_one :factura validates_presence_of :nombre end
Ruby
class Convenio < ActiveRecord::Base has_many_with_attributes :bonificaciones has_many_with_attributes :compromisos has_many_with_attributes :objetivo_mensuales belongs_to :ejecutivo validates_presence_of :fecha_inicio, :fecha_termino, :participante_id CENTRO_CONSUMO = 1 CORPORATIVO = 2...
Ruby
# # To change this template, choose Tools | Templates # and open the template in the editor. class UnidadMedida CAJA = 0 BOTELLA = 1 UNIDADES_MEDIDA = { 'Caja' => CAJA, 'Botella' => BOTELLA } end
Ruby
class EvaluacionPremio < ActiveRecord::Base belongs_to :evaluacion validates_presence_of :participante_id, :marca_id, :venta_copas validates_numericality_of :venta_copas end
Ruby
class BusquedaConvenio < ActiveRecord::Base def consecutivo "%06d" % id + '/' + fecha_inicio.strftime("%Y") end end
Ruby
class ConcursoObjetivo < ActiveRecord::Base belongs_to :concurso DESCRIPCIONES = [ 'Stock de Tradicional congelado', 'Batallas y/o cocteleria con JCE, App, W. y V. Smir.', 'Hoja pegada del Concurso', 'Exhibicion especial en Barra o Contrabarra', 'Dobel y Agavero en carro de Licores', 'Congelador de Tradicional', 'B...
Ruby
class BonificacionDetalle < ActiveRecord::Base belongs_to :centro belongs_to :detalle_factura, :foreign_key => 'partida_id' INICIAL = 1 ABONO = 2 CARGO = 3 TIPO_REFERENCIA = { :bonificacion_especie => 1, :orden_salida => 2, :bonificacion_bolsa => 3 } REFERENCIA = { 1 => 'Bonific...
Ruby
# # To change this template, choose Tools | Templates # and open the template in the editor. require 'pdf/writer' require 'pdf/simpletable' class ComodatoPdf def initialize(comodato_id) @pdf = PDF::Writer.new(:paper => 'LETTER') @comodato = BienComodato.find(comodato_id) @pdf.select_font("Times-Roman"...
Ruby
class SolicitudMaterialDetalle < ActiveRecord::Base belongs_to :solicitud_material validates_presence_of :material_id, :cantidad, :costo_unitario validates_numericality_of :cantidad, :costo_unitario def importe unless cantidad.blank? && costo_unitario.blank? cantidad * costo_unitario else ...
Ruby
class PuntajeCentroConsumo < ActiveRecord::Base belongs_to :evaluacion belongs_to :centro CARGO = 2 ABONO = 1 validates_presence_of :evaluacion_id, :centro_id, :puntos, :operacion validates_numericality_of :puntos, :operacion end
Ruby
class RequisicionProducto < ActiveRecord::Base SOLICITADA = 0 AUTORIZADA = 1 ENTREGADA = 2 RECHAZADA = 3 STATUS_REQUISICION = { "Solicitada" => SOLICITADA, "Autorizada" => AUTORIZADA, "Entregada" => ENTREGADA, "Rechazada" => RECHAZADA } has_many_with_attributes :item_requisiciones...
Ruby
class EntradasCatalogo < ActiveRecord::Base validates_presence_of :valor, :on => :create validates_uniqueness_of :valor, :on => :create, :scope => [ :valor, :parent_value_id ] belongs_to :catalogo end
Ruby
class BusquedaCentro < ActiveRecord::Base def editable?(current_user) if current_user == ejecutivo_id return true end parents = Ejecutivo.find(ejecutivo_id).parent_list can_edit = false parents.each do |parent| can_edit = current_user == parent.id break if can_ed...
Ruby
class OrdenSalidaPresupuesto < ActiveRecord::Base belongs_to :orden_salida belongs_to :presupuesto validates_presence_of :presupuesto_id, :disponible validates_numericality_of :disponible end
Ruby
class Evaluacion < ActiveRecord::Base belongs_to :concurso has_many :evaluacion_ventas, :order => 'participante_id, marca_id' has_many :evaluacion_premios, :order => 'participante_id, marca_id' has_many :evaluacion_objetivos has_many :puntaje_meseros has_many :puntaje_centro_consumos has_many :canjes ...
Ruby
class Centro < ActiveRecord::Base has_many :empleados, :conditions => {:status_id => 1} has_many :facturas, :conditions => {:status_id => 1} has_many :concursos, :conditions => {:status_id => 1} has_many :promociones, :conditions => {:status_id => 1} has_many :presencias, :conditions => {:status_id => 1} ha...
Ruby
class OrdenSalida < ActiveRecord::Base belongs_to :ejecutivo belongs_to :centro has_many :orden_salida_detalles has_many :orden_salida_presupuestos TIPO_REFERENCIA = { :bonificacion_especie => 1, :evaluacion => 2, :presencia => 3, :promocion => 4 } REFERENCIA = { 1 => 'Bonificaci...
Ruby
class Promocion < ActiveRecord::Base belongs_to :centro has_many :apoyo_productos has_many :apoyo_materiales validates_presence_of :fecha_evento, :tipo_evento_id, :nombre, :marca_id validates_presence_of :contacto_cdc_nombre validates_presence_of :descripcion def consecutivo "%06d" % id + '/' ...
Ruby