Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Compra < ActiveRecord::Base
- belongs_to :bidon
- belongs_to :proveedor
- belongs_to :conductor
- belongs_to :user
- has_many :item_compras, :dependent => :destroy
- accepts_nested_attributes_for :item_compras,
- reject_if: RejectDeeplyNested.blank?,
- :allow_destroy => true
- end
- class ItemCompra < ActiveRecord::Base
- belongs_to :compra
- belongs_to :product
- belongs_to :calibre
- end
- class Product < ActiveRecord::Base
- has_many :item_compras, :dependent => :restrict_with_error
- end
- class Calibre < ActiveRecord::Base
- has_many :item_compras
- def to_s
- "#{numero}"
- end
- end
- create_table "item_compras", force: :cascade do |t|
- t.integer "compra_id"
- t.integer "product_id"
- t.integer "calibre_id"
- t.integer "cantidad_bidon"
- t.text "nota"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
- create_table "calibres", force: :cascade do |t|
- t.integer "numero"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
- create_table "products", force: :cascade do |t|
- t.string "name"
- t.text "descripcion"
- t.integer "stock", default: 0
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
- create_table "compras", force: :cascade do |t|
- t.integer "proveedor_id"
- t.integer "bidon_id"
- t.integer "conductor_id"
- t.string "state", default: "nueva_compra"
- t.float "gastos", default: 0.0
- t.integer "numero_camion", default: 0
- t.integer "mic", default: 0
- t.integer "factura", default: 0
- t.integer "total_for_kg"
- t.float "total_compra"
- t.integer "total_bidones"
- t.integer "user_id"
- t.float "total_deuda", default: 0.0
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement