comee_core 0.1.97 → 0.1.99

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
  SHA256:
3
- metadata.gz: 0cb92df3470f8c017719aaedbe6c51315760869a45a018f2c551a8d069d0f815
4
- data.tar.gz: d981a86bc337820f64b63b8f4e5d95d44482f772ff8f222b276f5f4b56ff6190
3
+ metadata.gz: f3b5b69ffae3e2702ed23106fbc360890ec375ae49c97a136b98baad2fec89d8
4
+ data.tar.gz: 5fc14c0bac612232d3d32bf4c2f1f0e98e75773adb2aa343d1b73387f8b92bac
5
5
  SHA512:
6
- metadata.gz: bb572acac1f0630247da9380f43d22edc32c289e3cdf998b91517f37eec10a9cd01edbf122e9183e0c5d8b61a2a04630d2a6fac679fad53e6ae9212541f2a590
7
- data.tar.gz: 76d0cf07ad78fccd24d09a9eb8db389e3a8c10801e0cd2898fe958918a99f0861e557d7185703b79bfbd3b18adaf858511fa3973b70991617dee3e481794cb2b
6
+ metadata.gz: 986aff6f5d73b35a540a16fbbdafc62a2c03911a6cd06430de431fa30f547994ec3038d90d38e37a8504f36547cb3f519f9804cc8828a54942b08b49752d2884
7
+ data.tar.gz: c4add758cc2d3c861a10b0c584f96abac453928bacd0ad5375150bc56233323d4c95a0aa5f617cfe036884efad323b900c39dc6579ae4baaa6fa7d4c0c3fd3a4
@@ -7,7 +7,7 @@ module Comee
7
7
  belongs_to :next_price, class_name: "Comee::Core::MasterPrice", optional: true
8
8
  belongs_to :product_lookup, optional: true
9
9
 
10
- validates :price_status, :purchase_price, :selling_price, presence: true
10
+ validates :purchase_price, :selling_price, presence: true
11
11
  validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
12
12
  validates :product_id, uniqueness: {scope: %i[supplier_id previous_price_id next_price_id status]}
13
13
  validate :validate_primary_price, :validate_product_lookup
@@ -5,6 +5,7 @@ module Comee
5
5
  before_save :compute_status
6
6
 
7
7
  enum :status, {past: 0, current: 1, future: 2}
8
+ enum :price_status, {draft: 0, approved: 1}
8
9
 
9
10
  scope :current, -> { where(status: Price.statuses[:current]) }
10
11
  scope :future, -> { where(status: Price.statuses[:future]) }
@@ -12,7 +13,7 @@ module Comee
12
13
  belongs_to :product
13
14
  belongs_to :unit
14
15
 
15
- validates :valid_from, :valid_to, presence: true
16
+ validates :price_status, :valid_from, :valid_to, presence: true
16
17
  validate :validate_price_validity_dates
17
18
 
18
19
  def validate_price_validity_dates
@@ -5,11 +5,11 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
5
5
  t.float :selling_price, null: false
6
6
  t.date :valid_from, null: false
7
7
  t.date :valid_to, null: false
8
- t.float :status, null: false, default: 0
8
+ t.integer :status, null: false, default: 0
9
+ t.integer :price_status, null: false, default: 0
9
10
  t.boolean :primary, null: false, default: false
10
11
  t.float :margin, null: false, default: 0
11
12
  t.integer :lead_time
12
- t.integer :price_status, null: false, default: 0
13
13
  t.references :product,
14
14
  null: false,
15
15
  index: {name: "product_on_ccmp_indx"},
@@ -4,7 +4,8 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
4
4
  t.date :valid_from, null: false
5
5
  t.date :valid_to, null: false
6
6
  t.float :price, null: false
7
- t.float :status, null: false, default: 0
7
+ t.integer :status, null: false, default: 0
8
+ t.integer :price_status, null: false, default: 0
8
9
  t.float :margin, null: false, default: 0
9
10
  t.integer :margin_type, null: false, default: 0
10
11
  t.references :product,
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.97".freeze
3
+ VERSION = "0.1.99".freeze
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ FactoryBot.define do
2
2
  factory :client_price, class: "Comee::Core::ClientPrice" do
3
3
  valid_from { Date.current.advance(months: -1) }
4
4
  valid_to { Date.current.advance(months: 1) }
5
- status { 0 }
5
+ price_status { Comee::Core::Price.price_statuses[:draft] }
6
6
  price { 100 }
7
7
  product
8
8
  client
@@ -7,7 +7,7 @@ FactoryBot.define do
7
7
  primary { false }
8
8
  margin { 10.0 }
9
9
  lead_time { nil }
10
- status { Comee::Core::MasterPrice.statuses[:draft] }
10
+ price_status { Comee::Core::Price.price_statuses[:draft] }
11
11
  product
12
12
  supplier
13
13
  unit
@@ -16,6 +16,10 @@ FactoryBot.define do
16
16
  product_lookup { nil }
17
17
  propagated_to_client { false }
18
18
 
19
+ trait :approved do
20
+ price_status { Comee::Core::Price.price_statuses[:approved] }
21
+ end
22
+
19
23
  trait :past do
20
24
  valid_from { Date.current.advance(months: -2) }
21
25
  valid_to { Date.current.advance(months: -1) }
@@ -60,6 +64,7 @@ FactoryBot.define do
60
64
  previous_price: price
61
65
  )
62
66
  price.next_price = next_price
67
+ price.price_status = Comee::Core::Price.price_statuses[:approved]
63
68
  price.save!
64
69
  price
65
70
  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.97
4
+ version: 0.1.99
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-20 00:00:00.000000000 Z
11
+ date: 2024-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers