Signed-off-by: Adrian Hinz <ahinz@voicetelecom.pl>
This commit is contained in:
parent
61e40939bf
commit
6448fc0281
|
|
@ -3,4 +3,30 @@ class ProductsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def product_params
|
||||||
|
params.require(:product).permit(:name, :vat_id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
class Product < ApplicationRecord
|
||||||
|
belongs_to :vat
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
class UserFirm < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
class Vat < ApplicationRecord
|
||||||
|
has_many :products
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateVats < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :vats do |t|
|
||||||
|
t.string :name
|
||||||
|
t.date :start_date
|
||||||
|
t.decimal :tax_rate, { precision: 6, scale: 2 }
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateProducts < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :products do |t|
|
||||||
|
t.string :name
|
||||||
|
t.references :vat, foreign_key: true
|
||||||
|
t.decimal :netto_price, { precision: 18, scale: 2 }
|
||||||
|
t.string :qnt_name
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
class CreateUserFirms < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :user_firms do |t|
|
||||||
|
t.references :user, foreign_key: true
|
||||||
|
t.string :name
|
||||||
|
t.string :street
|
||||||
|
t.string :postcode
|
||||||
|
t.string :city
|
||||||
|
t.string :nip
|
||||||
|
t.string :regon
|
||||||
|
t.string :bank_name
|
||||||
|
t.string :bank_account
|
||||||
|
t.boolean :main
|
||||||
|
t.boolean :active
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
39
db/schema.rb
39
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160930103815) do
|
ActiveRecord::Schema.define(version: 20161003081718) do
|
||||||
|
|
||||||
create_table "customers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
create_table "customers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
|
@ -23,6 +23,33 @@ ActiveRecord::Schema.define(version: 20160930103815) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.integer "vat_id"
|
||||||
|
t.decimal "netto_price", precision: 18, scale: 2
|
||||||
|
t.string "qnt_name"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["vat_id"], name: "index_products_on_vat_id", using: :btree
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "user_firms", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "name"
|
||||||
|
t.string "street"
|
||||||
|
t.string "postcode"
|
||||||
|
t.string "city"
|
||||||
|
t.string "nip"
|
||||||
|
t.string "regon"
|
||||||
|
t.string "bank_name"
|
||||||
|
t.string "bank_account"
|
||||||
|
t.boolean "main"
|
||||||
|
t.boolean "active"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_user_firms_on_user_id", using: :btree
|
||||||
|
end
|
||||||
|
|
||||||
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
t.string "encrypted_password", default: "", null: false
|
t.string "encrypted_password", default: "", null: false
|
||||||
|
|
@ -40,4 +67,14 @@ ActiveRecord::Schema.define(version: 20160930103815) do
|
||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "vats", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.date "start_date"
|
||||||
|
t.decimal "tax_rate", precision: 6, scale: 2
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_foreign_key "products", "vats"
|
||||||
|
add_foreign_key "user_firms", "users"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
name: MyString
|
||||||
|
vat: one
|
||||||
|
netto_price:
|
||||||
|
qnt_name: MyString
|
||||||
|
|
||||||
|
two:
|
||||||
|
name: MyString
|
||||||
|
vat: two
|
||||||
|
netto_price:
|
||||||
|
qnt_name: MyString
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
user: one
|
||||||
|
name: MyString
|
||||||
|
street: MyString
|
||||||
|
postcode: MyString
|
||||||
|
city: MyString
|
||||||
|
nip: MyString
|
||||||
|
regon: MyString
|
||||||
|
bank_name: MyString
|
||||||
|
bank_account: MyString
|
||||||
|
main: false
|
||||||
|
active: false
|
||||||
|
|
||||||
|
two:
|
||||||
|
user: two
|
||||||
|
name: MyString
|
||||||
|
street: MyString
|
||||||
|
postcode: MyString
|
||||||
|
city: MyString
|
||||||
|
nip: MyString
|
||||||
|
regon: MyString
|
||||||
|
bank_name: MyString
|
||||||
|
bank_account: MyString
|
||||||
|
main: false
|
||||||
|
active: false
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
name: MyString
|
||||||
|
start_date: 2016-10-03
|
||||||
|
tax_rate:
|
||||||
|
|
||||||
|
two:
|
||||||
|
name: MyString
|
||||||
|
start_date: 2016-10-03
|
||||||
|
tax_rate:
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ProductTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class UserFirmTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class VatTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue