comee_core 0.1.36 → 0.1.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/products_controller.rb +2 -1
- data/app/models/comee/core/client_price.rb +2 -0
- data/app/models/comee/core/master_price.rb +3 -0
- data/app/models/comee/core/product.rb +1 -0
- data/db/migrate/20230728014322_create_comee_core_products.rb +2 -0
- data/db/migrate/20230813235946_create_comee_core_master_prices.rb +4 -0
- data/db/migrate/20230814151601_create_comee_core_client_prices.rb +4 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/client_prices.rb +1 -0
- data/spec/factories/comee/core/master_prices.rb +1 -0
- data/spec/factories/comee/core/products.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d518d7f15ac11cb1ec5a0012735296eb98ae3ba1a93b5601d85e7fe63d7b5956
|
4
|
+
data.tar.gz: 6dee4dcf892b4938f1f7fab7b1d7c527b2a11aad1295c816b67db553c6ba7b32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7da654c516653060647c6dcc8f8d5e8a40cd71ae6add8b4ee88801cb7b1b90951ba677301ccfee0855d08fd70bd941d81ddc5b22ab72342f8ebdb80c239bf1dd
|
7
|
+
data.tar.gz: 91676640c9c221f560007d0058eb628f61b1d9567b5e8227775125b3bc16d0b874cb4206300eca0fd796da45ceee57a37e02c36ab599580cf79652dfc5041133
|
@@ -6,6 +6,7 @@ module Comee
|
|
6
6
|
def index
|
7
7
|
super do
|
8
8
|
products = Comee::Core::Product.all
|
9
|
+
products = products.where(ancestry: nil) if params[:root_only].present?
|
9
10
|
products.then(&paginate)
|
10
11
|
end
|
11
12
|
end
|
@@ -13,7 +14,7 @@ module Comee
|
|
13
14
|
private
|
14
15
|
|
15
16
|
def model_params
|
16
|
-
params.required(:payload).permit(:code, :name, :description, :product_type_id, :unit_id, :metadata)
|
17
|
+
params.required(:payload).permit(:code, :name, :description, :product_type_id, :unit_id, :metadata, :parent_id)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -3,6 +3,7 @@ module Comee
|
|
3
3
|
class ClientPrice < Price
|
4
4
|
belongs_to :client
|
5
5
|
belongs_to :previous_price, class_name: "Comee::Core::ClientPrice", optional: true
|
6
|
+
belongs_to :next_price, class_name: "Comee::Core::ClientPrice", optional: true
|
6
7
|
|
7
8
|
validates :price, presence: true
|
8
9
|
validates :price, numericality: {greater_than: 0}
|
@@ -18,6 +19,7 @@ module Comee
|
|
18
19
|
product_id
|
19
20
|
client_id
|
20
21
|
previous_price_id
|
22
|
+
next_price_id
|
21
23
|
]
|
22
24
|
end
|
23
25
|
|
@@ -3,6 +3,7 @@ module Comee
|
|
3
3
|
class MasterPrice < Price
|
4
4
|
belongs_to :supplier
|
5
5
|
belongs_to :previous_price, class_name: "Comee::Core::MasterPrice", optional: true
|
6
|
+
belongs_to :next_price, class_name: "Comee::Core::MasterPrice", optional: true
|
6
7
|
|
7
8
|
validates :purchase_price, :selling_price, presence: true
|
8
9
|
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
@@ -11,6 +12,7 @@ module Comee
|
|
11
12
|
|
12
13
|
scope :current_primary, -> { where(primary: true).current }
|
13
14
|
scope :unapplied, -> { where(propagated_to_client: false).current_primary }
|
15
|
+
scope :product_price, ->(product_id) { find_by(product_id: product_id, primary: true, status: Price.statuses[:current]) }
|
14
16
|
|
15
17
|
def validate_primary_price
|
16
18
|
return unless product && primary
|
@@ -31,6 +33,7 @@ module Comee
|
|
31
33
|
product_id
|
32
34
|
supplier_id
|
33
35
|
previous_price_id
|
36
|
+
next_price_id
|
34
37
|
]
|
35
38
|
end
|
36
39
|
|
@@ -24,6 +24,10 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
|
|
24
24
|
null: true,
|
25
25
|
index: {name: "previous_price_on_ccsp_indx"},
|
26
26
|
foreign_key: {to_table: :comee_core_master_prices}
|
27
|
+
t.references :next_price,
|
28
|
+
null: true,
|
29
|
+
index: {name: "next_price_on_ccsp_indx"},
|
30
|
+
foreign_key: {to_table: :comee_core_master_prices}
|
27
31
|
t.boolean :propagated_to_client, null: false, default: false
|
28
32
|
|
29
33
|
t.timestamps
|
@@ -22,6 +22,10 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
22
22
|
null: true,
|
23
23
|
index: {name: "previous_price_on_cccp_indx"},
|
24
24
|
foreign_key: {to_table: :comee_core_client_prices}
|
25
|
+
t.references :next_price,
|
26
|
+
null: true,
|
27
|
+
index: {name: "next_price_on_cccp_indx"},
|
28
|
+
foreign_key: {to_table: :comee_core_client_prices}
|
25
29
|
|
26
30
|
t.timestamps
|
27
31
|
end
|
data/lib/comee/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comee_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|