comee_core 0.1.36 → 0.1.38

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: 0073a3f0100eb17a82500a1ae15c6cc118262be70542bfc516b662990da3de40
4
- data.tar.gz: 70e6fc9c160b2f499c039e9697832980666ac5746493dab5f604d6e1ee6e51e6
3
+ metadata.gz: d518d7f15ac11cb1ec5a0012735296eb98ae3ba1a93b5601d85e7fe63d7b5956
4
+ data.tar.gz: 6dee4dcf892b4938f1f7fab7b1d7c527b2a11aad1295c816b67db553c6ba7b32
5
5
  SHA512:
6
- metadata.gz: 4232e5d33dd769a1021f9e607d4016ed77f75bb1e6a60ed408be97a3b7b03ef7e077906f067b65c77e2689f52d3a1a7bded880661fd9166e9d319c87ac5d95b0
7
- data.tar.gz: 9dc773b6faeec9c77ac2b8f35d76e576ca614ce8bd5159a45f55cc30aa01a11a8591d041239de98199cae732153911ea71c266f1a7ee3fea8adff7b2fcd7c137
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
 
@@ -4,6 +4,7 @@ module Comee
4
4
  belongs_to :product_type
5
5
  belongs_to :unit
6
6
  has_many :inventories
7
+ has_ancestry
7
8
 
8
9
  validates :code, presence: true, uniqueness: true
9
10
  validates :name, presence: true
@@ -13,6 +13,8 @@ class CreateComeeCoreProducts < ActiveRecord::Migration[7.0]
13
13
  null: false,
14
14
  index: {name: "unit_on_ccp_indx"},
15
15
  foreign_key: {to_table: :comee_core_units}
16
+ t.string "ancestry", collation: "C"
17
+ t.index "ancestry"
16
18
 
17
19
  t.timestamps
18
20
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.36".freeze
3
+ VERSION = "0.1.38".freeze
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ FactoryBot.define do
9
9
  unit
10
10
  discount { 0 }
11
11
  previous_price { nil }
12
+ next_price { nil }
12
13
 
13
14
  trait :past do
14
15
  valid_from { Date.current.advance(months: -2) }
@@ -10,6 +10,7 @@ FactoryBot.define do
10
10
  supplier
11
11
  unit
12
12
  previous_price { nil }
13
+ next_price { nil }
13
14
  propagated_to_client { false }
14
15
 
15
16
  trait :past do
@@ -6,5 +6,6 @@ FactoryBot.define do
6
6
  metadata { {} }
7
7
  product_type
8
8
  unit
9
+ ancestry { nil }
9
10
  end
10
11
  end
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.36
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-21 00:00:00.000000000 Z
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