comee_core 0.1.78 → 0.1.80
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/comee/core/client.rb +6 -1
- data/app/models/comee/core/client_price.rb +12 -0
- data/app/models/comee/core/master_price.rb +12 -1
- 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/shipment_items.rb +1 -1
- metadata +3 -3
- /data/db/migrate/{20230914041307_create_comee_core_product_lookups.rb → 20230813041307_create_comee_core_product_lookups.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e66de25a6395ee13f7dd5bdf45a79d8fdda48df5037197f499c5000b2cd965e
|
4
|
+
data.tar.gz: f19d317e6465ebadc10aa01674f7e39651e9fa11a8875c62adadd418a8cad0f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c3b34e1015e9bd2b71d28d575514de6c346d5dc00e073160f28a6cfa15a78172b9b7215154c3f435d395ceeeb1e9062a2ba90a455073f5b752a62b037652b4
|
7
|
+
data.tar.gz: c57d6182fe854968524ef8184c5f92163e0c15e8c7fcf2f81fe46ef2e1b1de1d71587a9edfa609bbfe22ac56b1201a22cf162137829a24b3e462a679c3cf330b
|
@@ -8,7 +8,7 @@ module Comee
|
|
8
8
|
validates :code, :name, :address, :locale, presence: true
|
9
9
|
validates :code, uniqueness: true
|
10
10
|
|
11
|
-
delegate(:name, to: :user, prefix: true)
|
11
|
+
delegate(:name, to: :user, prefix: true, allow_nil: true)
|
12
12
|
|
13
13
|
def self.ransackable_attributes(_auth_object = nil)
|
14
14
|
%w[
|
@@ -17,8 +17,13 @@ module Comee
|
|
17
17
|
code
|
18
18
|
name
|
19
19
|
locale
|
20
|
+
parent_id
|
20
21
|
]
|
21
22
|
end
|
23
|
+
|
24
|
+
def self.ransackable_associations(_auth_object = nil)
|
25
|
+
["parent"]
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -5,11 +5,23 @@ module Comee
|
|
5
5
|
belongs_to :client
|
6
6
|
belongs_to :previous_price, class_name: "Comee::Core::ClientPrice", optional: true
|
7
7
|
belongs_to :next_price, class_name: "Comee::Core::ClientPrice", optional: true
|
8
|
+
belongs_to :product_lookup, optional: true
|
8
9
|
|
9
10
|
validates :price, :margin_type, presence: true
|
10
11
|
validates :price, numericality: {greater_than: 0}
|
11
12
|
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
12
13
|
validates :product_id, uniqueness: {scope: %i[client_id previous_price_id next_price_id status]}
|
14
|
+
validate :validate_product_lookup
|
15
|
+
|
16
|
+
def validate_product_lookup
|
17
|
+
return unless product_lookup && product && client
|
18
|
+
|
19
|
+
if product_lookup.itemable_id != client_id ||
|
20
|
+
product_lookup.itemable_type != "Comee::Core::Client" ||
|
21
|
+
product_lookup.product_id != product_id
|
22
|
+
errors.add(:product_lookup, "contains wrong client or product.")
|
23
|
+
end
|
24
|
+
end
|
13
25
|
|
14
26
|
def self.ransackable_attributes(_auth_object = nil)
|
15
27
|
%w[
|
@@ -4,11 +4,12 @@ module Comee
|
|
4
4
|
belongs_to :supplier
|
5
5
|
belongs_to :previous_price, class_name: "Comee::Core::MasterPrice", optional: true
|
6
6
|
belongs_to :next_price, class_name: "Comee::Core::MasterPrice", optional: true
|
7
|
+
belongs_to :product_lookup, optional: true
|
7
8
|
|
8
9
|
validates :purchase_price, :selling_price, presence: true
|
9
10
|
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
10
11
|
validates :product_id, uniqueness: {scope: %i[supplier_id previous_price_id next_price_id status]}
|
11
|
-
validate :validate_primary_price
|
12
|
+
validate :validate_primary_price, :validate_product_lookup
|
12
13
|
|
13
14
|
scope :current_primary, -> { where(primary: true).current }
|
14
15
|
scope :unapplied, -> { where(propagated_to_client: false).current_primary }
|
@@ -30,6 +31,16 @@ module Comee
|
|
30
31
|
errors.add(:base, "There is already a primary price entry for item '#{product.code}'")
|
31
32
|
end
|
32
33
|
|
34
|
+
def validate_product_lookup
|
35
|
+
return unless product_lookup && product && supplier
|
36
|
+
|
37
|
+
if product_lookup.itemable_id != supplier_id ||
|
38
|
+
product_lookup.itemable_type != "Comee::Core::Supplier" ||
|
39
|
+
product_lookup.product_id != product_id
|
40
|
+
errors.add(:product_lookup, "contains wrong supplier or product.")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
33
44
|
def self.ransackable_attributes(_auth_object = nil)
|
34
45
|
%w[
|
35
46
|
valid_from
|
@@ -29,6 +29,10 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
|
|
29
29
|
null: true,
|
30
30
|
index: {name: "next_price_on_ccsp_indx"},
|
31
31
|
foreign_key: {to_table: :comee_core_master_prices}
|
32
|
+
t.references :product_lookup,
|
33
|
+
null: true,
|
34
|
+
index: {name: "pl_on_ccmp_indx"},
|
35
|
+
foreign_key: {to_table: :comee_core_product_lookups}
|
32
36
|
t.boolean :propagated_to_client, null: false, default: false
|
33
37
|
|
34
38
|
t.timestamps
|
@@ -27,6 +27,10 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
27
27
|
null: true,
|
28
28
|
index: {name: "next_price_on_cccp_indx"},
|
29
29
|
foreign_key: {to_table: :comee_core_client_prices}
|
30
|
+
t.references :product_lookup,
|
31
|
+
null: true,
|
32
|
+
index: {name: "pl_on_cccp_indx"},
|
33
|
+
foreign_key: {to_table: :comee_core_product_lookups}
|
30
34
|
|
31
35
|
t.timestamps
|
32
36
|
end
|
data/lib/comee/core/version.rb
CHANGED
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :shipment_item, class: "Comee::Core::ShipmentItem" do
|
3
3
|
sales_order_item
|
4
4
|
quantity { 50 }
|
5
|
-
shipment_status {
|
5
|
+
shipment_status { Comee::Core::ItemStatus::INITIALIZED }
|
6
6
|
status { Comee::Core::ShipmentItem.statuses[:active] }
|
7
7
|
handover_date { Date.current.advance(days: 3) }
|
8
8
|
delivery_date { Date.current.advance(days: 6) }
|
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.80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -401,9 +401,9 @@ files:
|
|
401
401
|
- db/migrate/20230811102708_create_comee_core_customer_order_items.rb
|
402
402
|
- db/migrate/20230812190652_create_comee_core_sales_orders.rb
|
403
403
|
- db/migrate/20230812212844_create_comee_core_sales_order_items.rb
|
404
|
+
- db/migrate/20230813041307_create_comee_core_product_lookups.rb
|
404
405
|
- db/migrate/20230813235946_create_comee_core_master_prices.rb
|
405
406
|
- db/migrate/20230814151601_create_comee_core_client_prices.rb
|
406
|
-
- db/migrate/20230914041307_create_comee_core_product_lookups.rb
|
407
407
|
- db/migrate/20230915205522_create_comee_core_invoices.rb
|
408
408
|
- db/migrate/20230915205648_create_comee_core_invoice_items.rb
|
409
409
|
- db/migrate/20230929115336_create_comee_core_order_sources.rb
|