rawgento_models 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e32f81b22beaeb6c618f513a3adcb2e60eed4ef8
4
- data.tar.gz: 65598237bd5c885f266f7d3ffe47d0eda347d7bc
3
+ metadata.gz: 7e08eb86f68a89d3a006545f7326ada10cee3999
4
+ data.tar.gz: f99866f97f2e411f2533683db6ce969cc7701206
5
5
  SHA512:
6
- metadata.gz: b38a650e978f6947eccf9543ae5507064a159ff04f20587a50e7c30623d1a61cafa54529244046af59c5e8cc5bf5fb9df77bcd962e91d4aeee5acc5973788af2
7
- data.tar.gz: 964f26eacd11847cbfa6fea7a7b4c4a7a562614450b3357da7987fee863419119c6e485f01a750b86d823e4861a7e5ccd6a3886cf6bd6abe9ec5cedf6aac8478
6
+ metadata.gz: f9ae1e4bb020ea103c3e7081d209bd3e2b94df50ccfae0282d64a0ea37dbc05412a8d86758310bd6fcbefdf6cefa77340a3d7453dc4262a87115e1bc53e001ad
7
+ data.tar.gz: fe99dc99208c008ebc66727d25b3b25c2f4ee6a6473bfcbd9ea447772974c4d89d8e2372b32ad24b327ec5924dabdf6830f3e3a7864cd73fd31277475289a0fa
data/README.md CHANGED
@@ -64,6 +64,10 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
64
64
 
65
65
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
66
 
67
+ ### Create new migrations
68
+
69
+ Its easiest to copy an existing migration (from db/migrate), adjust the timestamp in the file name and replace the actual migration code.
70
+
67
71
  ## Contributing
68
72
 
69
73
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rawgento_models. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -0,0 +1,8 @@
1
+ class ExtendSupplierFields < ActiveRecord::Migration
2
+ def change
3
+ add_column :suppliers, :delivery_time_days, :integer
4
+ add_column :suppliers, :order_info, :text
5
+ add_column :suppliers, :minimum_order_value, :decimal
6
+ end
7
+ end
8
+
@@ -0,0 +1,5 @@
1
+ class AddPurchasePriceToLocalProduct < ActiveRecord::Migration
2
+ def change
3
+ add_column :local_products, :purchase_price, :decimal
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddOrderInfoToLocalProduct < ActiveRecord::Migration
2
+ def change
3
+ add_column :local_products, :order_info, :text
4
+ end
5
+ end
data/db/schema.rb CHANGED
@@ -11,28 +11,33 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 201601251100) do
14
+ ActiveRecord::Schema.define(version: 201608011715) do
15
15
 
16
16
  create_table "local_products", force: :cascade do |t|
17
17
  t.string "name"
18
- t.string "supplier"
19
18
  t.integer "product_id"
20
- t.datetime "created_at", null: false
21
- t.datetime "updated_at", null: false
22
- t.integer "shelve_nr"
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
+ t.string "shelve_nr"
23
22
  t.integer "packsize"
24
- t.boolean "active", default: true
23
+ t.boolean "active", default: true
24
+ t.integer "supplier_id"
25
+ t.string "supplier_sku"
26
+ t.string "supplier_prod_name"
27
+ t.decimal "purchase_price"
28
+ t.text "order_info"
25
29
  end
26
30
 
27
31
  add_index "local_products", ["product_id"], name: "index_local_products_on_product_id", unique: true
32
+ add_index "local_products", ["supplier_id"], name: "index_local_products_on_supplier_id"
28
33
 
29
34
  create_table "order_items", force: :cascade do |t|
30
- t.integer "order_id", null: false
31
- t.string "state"
35
+ t.integer "order_id", null: false
36
+ t.string "state", default: "new"
32
37
  t.integer "num_wished"
33
38
  t.integer "num_ordered"
34
- t.datetime "created_at", null: false
35
- t.datetime "updated_at", null: false
39
+ t.datetime "created_at", null: false
40
+ t.datetime "updated_at", null: false
36
41
  t.integer "local_product_id"
37
42
  t.integer "current_stock"
38
43
  t.integer "min_stock"
@@ -41,21 +46,25 @@ ActiveRecord::Schema.define(version: 201601251100) do
41
46
  add_index "order_items", ["local_product_id"], name: "index_order_items_on_local_product_id"
42
47
 
43
48
  create_table "orders", force: :cascade do |t|
44
- t.string "state"
45
- t.datetime "created_at", null: false
46
- t.datetime "updated_at", null: false
49
+ t.string "state", default: "new"
50
+ t.datetime "created_at", null: false
51
+ t.datetime "updated_at", null: false
52
+ t.integer "supplier_id"
47
53
  end
48
54
 
55
+ add_index "orders", ["supplier_id"], name: "index_orders_on_supplier_id"
56
+
49
57
  create_table "remote_products", force: :cascade do |t|
50
58
  t.string "name"
51
- t.string "supplier"
52
59
  t.integer "local_product_id"
53
60
  t.integer "product_id"
54
61
  t.datetime "created_at", null: false
55
62
  t.datetime "updated_at", null: false
63
+ t.integer "supplier_id"
56
64
  end
57
65
 
58
66
  add_index "remote_products", ["local_product_id"], name: "index_remote_products_on_local_product_id"
67
+ add_index "remote_products", ["supplier_id"], name: "index_remote_products_on_supplier_id"
59
68
 
60
69
  create_table "stock_items", force: :cascade do |t|
61
70
  t.integer "local_product_id"
@@ -67,4 +76,18 @@ ActiveRecord::Schema.define(version: 201601251100) do
67
76
 
68
77
  add_index "stock_items", ["local_product_id"], name: "index_stock_items_on_local_product_id"
69
78
 
79
+ create_table "suppliers", force: :cascade do |t|
80
+ t.string "name"
81
+ t.boolean "remote_shop", default: false
82
+ t.datetime "created_at", null: false
83
+ t.datetime "updated_at", null: false
84
+ t.string "email"
85
+ t.text "order_template"
86
+ t.integer "delivery_time_days"
87
+ t.text "order_info"
88
+ t.decimal "minimum_order_value"
89
+ end
90
+
91
+ add_index "suppliers", ["name"], name: "index_suppliers_on_name"
92
+
70
93
  end
@@ -4,6 +4,7 @@ module RawgentoModels
4
4
  belongs_to :supplier
5
5
 
6
6
  scope :queued, -> { where(state: "queued") }
7
+ scope :in_state, ->(state) { where(state: state) }
7
8
 
8
9
  def self.current
9
10
  find_by(state: "new")
@@ -21,6 +21,14 @@ module RawgentoModels
21
21
  num_ordered == 0
22
22
  end
23
23
 
24
+ def ordered?
25
+ !not_ordered?
26
+ end
27
+
28
+ def not_ordered?
29
+ num_ordered.nil?
30
+ end
31
+
24
32
  def order_item_same_product before
25
33
  time_range = Date.civil(1970, 1, 1)..before
26
34
  OrderItem.where(local_product_id: self.local_product_id)
@@ -1,3 +1,3 @@
1
1
  module RawgentoModels
2
- VERSION = "0.2.4".freeze
2
+ VERSION = "0.2.5".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rawgento_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -107,6 +107,9 @@ files:
107
107
  - db/migrate/201605291700_add_email_and_order_template_to_supplier.rb
108
108
  - db/migrate/201605291800_add_supplier_to_order.rb
109
109
  - db/migrate/201607111745_add_supplier_attributes_to_local_product.rb
110
+ - db/migrate/201608011400_extend_supplier_fields.rb
111
+ - db/migrate/201608011700_add_purchase_price_to_local_product.rb
112
+ - db/migrate/201608011715_add_order_info_to_local_product.rb
110
113
  - db/schema.rb
111
114
  - exe/rawgento_models
112
115
  - lib/rawgento_models.rb