+
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
new file mode 100644
index 0000000..0e0d345
--- /dev/null
+++ b/app/views/products/new.html.erb
@@ -0,0 +1,11 @@
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 5dc5e2d..4e2991c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,10 +1,10 @@
Rails.application.routes.draw do
- get 'invoices/index'
get 'settings/index'
devise_for :users
resources :products
+ resources :invoices
resources :customers
diff --git a/db/migrate/20161004195824_create_invoices.rb b/db/migrate/20161004195824_create_invoices.rb
new file mode 100644
index 0000000..f760e22
--- /dev/null
+++ b/db/migrate/20161004195824_create_invoices.rb
@@ -0,0 +1,14 @@
+class CreateInvoices < ActiveRecord::Migration[5.0]
+ def change
+ create_table :invoices do |t|
+ t.references :user, foreign_key: true
+ t.references :user_firm, foreign_key: true
+ t.references :customer, foreign_key: true
+ t.string :number
+ t.date :date
+ t.date :date_of_payment
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20161004200042_create_invoice_products.rb b/db/migrate/20161004200042_create_invoice_products.rb
new file mode 100644
index 0000000..a80e0ec
--- /dev/null
+++ b/db/migrate/20161004200042_create_invoice_products.rb
@@ -0,0 +1,12 @@
+class CreateInvoiceProducts < ActiveRecord::Migration[5.0]
+ def change
+ create_table :invoice_products do |t|
+ t.references :invoice, foreign_key: true
+ t.references :product, foreign_key: true
+ t.decimal :netto_price, { precision: 18, scale: 2 }
+ t.decimal :qty, { precision: 18, scale: 3 }
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d86cee1..c09f18e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161003103325) do
+ActiveRecord::Schema.define(version: 20161004200042) do
create_table "customers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.string "name"
@@ -25,6 +25,31 @@ ActiveRecord::Schema.define(version: 20161003103325) do
t.index ["user_id"], name: "index_customers_on_user_id", using: :btree
end
+ create_table "invoice_products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
+ t.integer "invoice_id"
+ t.integer "product_id"
+ t.decimal "netto_price", precision: 18, scale: 2
+ t.decimal "qty", precision: 18, scale: 3
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["invoice_id"], name: "index_invoice_products_on_invoice_id", using: :btree
+ t.index ["product_id"], name: "index_invoice_products_on_product_id", using: :btree
+ end
+
+ create_table "invoices", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
+ t.integer "user_id"
+ t.integer "user_firm_id"
+ t.integer "customer_id"
+ t.string "number"
+ t.date "date"
+ t.date "date_of_payment"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["customer_id"], name: "index_invoices_on_customer_id", using: :btree
+ t.index ["user_firm_id"], name: "index_invoices_on_user_firm_id", using: :btree
+ t.index ["user_id"], name: "index_invoices_on_user_id", using: :btree
+ 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"
@@ -80,6 +105,11 @@ ActiveRecord::Schema.define(version: 20161003103325) do
end
add_foreign_key "customers", "users"
+ add_foreign_key "invoice_products", "invoices"
+ add_foreign_key "invoice_products", "products"
+ add_foreign_key "invoices", "customers"
+ add_foreign_key "invoices", "user_firms"
+ add_foreign_key "invoices", "users"
add_foreign_key "products", "users"
add_foreign_key "products", "vats"
add_foreign_key "user_firms", "users"
diff --git a/test/fixtures/invoice_products.yml b/test/fixtures/invoice_products.yml
new file mode 100644
index 0000000..4f8cdbb
--- /dev/null
+++ b/test/fixtures/invoice_products.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ invoice: one
+ product: one
+ netto_price:
+ qty:
+
+two:
+ invoice: two
+ product: two
+ netto_price:
+ qty:
diff --git a/test/fixtures/invoices.yml b/test/fixtures/invoices.yml
new file mode 100644
index 0000000..0a780ea
--- /dev/null
+++ b/test/fixtures/invoices.yml
@@ -0,0 +1,17 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ user: one
+ user_firm: one
+ customer: one
+ number: MyString
+ date: 2016-10-04
+ date_of_payment: 2016-10-04
+
+two:
+ user: two
+ user_firm: two
+ customer: two
+ number: MyString
+ date: 2016-10-04
+ date_of_payment: 2016-10-04
diff --git a/test/models/invoice_product_test.rb b/test/models/invoice_product_test.rb
new file mode 100644
index 0000000..55ab5e1
--- /dev/null
+++ b/test/models/invoice_product_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class InvoiceProductTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/invoice_test.rb b/test/models/invoice_test.rb
new file mode 100644
index 0000000..25dd32c
--- /dev/null
+++ b/test/models/invoice_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class InvoiceTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end