comee_core 0.1.79 → 0.1.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d71a8200c433afbae99cbd4b1ca79c35eee1213e1192ebe7e0af4094f172bc41
4
- data.tar.gz: fa8fd302ec0376de853aa014d980f261c6cbabe517c1f7a5e1723a887271a98e
3
+ metadata.gz: 8e66de25a6395ee13f7dd5bdf45a79d8fdda48df5037197f499c5000b2cd965e
4
+ data.tar.gz: f19d317e6465ebadc10aa01674f7e39651e9fa11a8875c62adadd418a8cad0f8
5
5
  SHA512:
6
- metadata.gz: 62e97416902c0185884d83f89bd19ea26a0b02e9a7aae46c8e144a57c2adeb9207fe577899490617eb75a2aadbcf868e30ec5443d0e8ffb12c7beef5f81acaee
7
- data.tar.gz: 44d4a262ac39c7e97c7096cdc214ed842bf1f764d4b4233038decf27ef38fbcef8aba9d5e60622ba2ce9674ba7fc2775847c5775c615eaf0e7dda4972dc0df6e
6
+ metadata.gz: f0c3b34e1015e9bd2b71d28d575514de6c346d5dc00e073160f28a6cfa15a78172b9b7215154c3f435d395ceeeb1e9062a2ba90a455073f5b752a62b037652b4
7
+ data.tar.gz: c57d6182fe854968524ef8184c5f92163e0c15e8c7fcf2f81fe46ef2e1b1de1d71587a9edfa609bbfe22ac56b1201a22cf162137829a24b3e462a679c3cf330b
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.79".freeze
3
+ VERSION = "0.1.80".freeze
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ FactoryBot.define do
11
11
  margin_type { Comee::Core::ClientPrice.margin_types[:increase] }
12
12
  previous_price { nil }
13
13
  next_price { nil }
14
+ product_lookup { nil }
14
15
 
15
16
  trait :past do
16
17
  valid_from { Date.current.advance(months: -2) }
@@ -12,6 +12,7 @@ FactoryBot.define do
12
12
  unit
13
13
  previous_price { nil }
14
14
  next_price { nil }
15
+ product_lookup { nil }
15
16
  propagated_to_client { false }
16
17
 
17
18
  trait :past do
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.79
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-05 00:00:00.000000000 Z
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