comee_core 0.1.33 → 0.1.35

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: 89be0ab79ac6789639448aaafa19ca5845e08e132d0d99c34eef619b97ece546
4
- data.tar.gz: f62cdbb0af85b33c2322d17d9289cdd12c2021cd28b1fa06332cc63c39847a01
3
+ metadata.gz: 13b98b025e67870310c1c5a59ed49190f520ac69c4f4f66d6d6e59c3887b0e56
4
+ data.tar.gz: 4403b249eb4659a7198c27d218b4df9d84bcd352933540f093f44d150f837e68
5
5
  SHA512:
6
- metadata.gz: 5fca168ac18ac7ceef8614bdb8792f4395e21107cb62adfc9b9ac1d7b4301f8b418e3bdb5968f9b8fd4c4ebcebaf3517cb13fcda854ef1c36bb059943ac42b59
7
- data.tar.gz: 6369177eb65524a12f58c1f2469b9fc3114a587edc0bdc7b6b64dc98e1655433910325fa4d3864fce8f861dbb866694f3079171e91f18d9a5d48c9d1c01a9e16
6
+ metadata.gz: 4070797618a46ce5da8102c5056c464bb688fc91fc802af00f9a6d8e3c5e24507bbd56fc4f9eeda2bbffa6c486cb0740b26a480ff01609f840fbad1efe47693c
7
+ data.tar.gz: ea97a4615f87b8ab8f1c6929d4c15c8c71f24229c58cf6cedbee93e19a9388b224763c2aa2ab0a4921d5456ae8fcd1d65964a07ece18a53f0dd1fe133a4897ed
@@ -18,7 +18,7 @@ module Comee
18
18
  private
19
19
 
20
20
  def model_params
21
- params.require(:payload).permit(:valid_from, :valid_to, :price, :status, :product_id, :discount, :client_id, :previous_price,
21
+ params.require(:payload).permit(:valid_from, :valid_to, :price, :product_id, :discount, :client_id, :previous_price,
22
22
  :unit_id)
23
23
  end
24
24
  end
@@ -15,8 +15,10 @@ module Comee
15
15
  def validate_primary_price
16
16
  return unless product && primary
17
17
 
18
- count = MasterPrice.where(product: product, primary: true, status: Price.statuses[:current]).count
19
- return unless count.positive? && primary && MasterPrice.statuses[status] == MasterPrice.statuses[:current]
18
+ prices = MasterPrice.where(product: product, primary: true)
19
+ unless prices.count.positive? && primary && MasterPrice.statuses[status] == MasterPrice.statuses[:current] && prices.first.id != id
20
+ return
21
+ end
20
22
 
21
23
  errors.add(:base, "There is already a primary price entry for item '#{product.code}'")
22
24
  end
@@ -32,6 +32,18 @@ module Comee
32
32
  self.status = Price.statuses[:future]
33
33
  end
34
34
  end
35
+
36
+ def past?
37
+ Price.statuses[status] == Price.statuses[:past]
38
+ end
39
+
40
+ def current?
41
+ Price.statuses[status] == Price.statuses[:current]
42
+ end
43
+
44
+ def future?
45
+ Price.statuses[status] == Price.statuses[:future]
46
+ end
35
47
  end
36
48
  end
37
49
  end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.33".freeze
3
+ VERSION = "0.1.35".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.33
4
+ version: 0.1.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.