comee_core 0.1.16 → 0.1.18
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_price.rb +1 -0
- data/app/models/comee/core/master_price.rb +1 -1
- data/app/utils/comee/core/period.rb +26 -2
- data/db/migrate/20230814151601_create_comee_core_client_prices.rb +1 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/back_orders.rb +1 -1
- data/spec/factories/comee/core/client_prices.rb +1 -0
- data/spec/factories/comee/core/clients.rb +1 -0
- data/spec/factories/comee/core/sales_order_items.rb +1 -1
- data/spec/factories/comee/core/sales_orders.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee3ab42e5f0909fdd7de5f6d1fc073a4fc79b34a606e3d87e4580b3770ebfb7
|
4
|
+
data.tar.gz: 44bc512432f7732f9b2e447d2a2cf0e2d3b54f73f93d6224622957c6c6b874d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afe5c968f62a1ce3b4831d6f76fec04818b085f28c8ef14853c84dbdee92768e429757362bf246993387aa0dbedbacac2106444e58497fd60b8f99373c1462f
|
7
|
+
data.tar.gz: bd830637c78c8bca22da8bd19baf3e3470c1e7e123fb5f4afb4711a459e0ebd71b28f1e7894af61387a88fe222110efbb127f4c5a822cca8b587c50a443c9a75
|
@@ -8,6 +8,7 @@ module Comee
|
|
8
8
|
|
9
9
|
validates :valid_from, :valid_to, :price, :status, presence: true
|
10
10
|
validates :price, numericality: {greater_than: 0}
|
11
|
+
validates :discount, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
11
12
|
validates :product_id, uniqueness: {scope: [:client_id, :previous_price_id]}
|
12
13
|
validate :validate_price_validity_dates
|
13
14
|
|
@@ -13,7 +13,7 @@ module Comee
|
|
13
13
|
def validate_primary_price
|
14
14
|
return unless product && primary
|
15
15
|
|
16
|
-
count = MasterPrice.where(product:, primary: true).count
|
16
|
+
count = MasterPrice.where(product:, primary: true, active: true).count
|
17
17
|
errors.add(:base, "There is already a primary supplier for item '#{product.code}'") if count.positive?
|
18
18
|
end
|
19
19
|
|
@@ -7,6 +7,18 @@ module Comee
|
|
7
7
|
@finish = finish
|
8
8
|
end
|
9
9
|
|
10
|
+
def ==(other)
|
11
|
+
self.class == other.class && @start == other.start && @finish == other.finish
|
12
|
+
end
|
13
|
+
|
14
|
+
def <(other)
|
15
|
+
instance_of?(other.class) && @start < other.start && @finish < other.finish
|
16
|
+
end
|
17
|
+
|
18
|
+
def >(other)
|
19
|
+
instance_of?(other.class) && @start > other.start && @finish > other.finish
|
20
|
+
end
|
21
|
+
|
10
22
|
def valid?
|
11
23
|
finish > start
|
12
24
|
end
|
@@ -23,13 +35,25 @@ module Comee
|
|
23
35
|
false
|
24
36
|
end
|
25
37
|
|
38
|
+
def disjoint?(period)
|
39
|
+
@finish < period.start || period.finish < @start
|
40
|
+
end
|
41
|
+
|
26
42
|
def overlaps?(period)
|
27
|
-
return true if period.start <= start && start <= period.finish
|
43
|
+
return true if period.start <= @start && @start <= period.finish
|
28
44
|
|
29
|
-
return true if start <= period.start && period.start <= finish
|
45
|
+
return true if @start <= period.start && period.start <= @finish
|
30
46
|
|
31
47
|
false
|
32
48
|
end
|
49
|
+
|
50
|
+
def self.compute_next_valid_period(period1, period2)
|
51
|
+
return period2 if period1.disjoint?(period2) && period1 < period2
|
52
|
+
|
53
|
+
return nil if period1 > period2 || period1.contains?(period2)
|
54
|
+
|
55
|
+
Period.new(period1.finish.advance(days: 1), period2.finish)
|
56
|
+
end
|
33
57
|
end
|
34
58
|
end
|
35
59
|
end
|
@@ -5,6 +5,7 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
5
5
|
t.date :valid_to, null: false
|
6
6
|
t.float :price, null: false
|
7
7
|
t.float :status, null: false, default: 0
|
8
|
+
t.integer :discount, null: false
|
8
9
|
t.references :product,
|
9
10
|
null: false,
|
10
11
|
index: {name: "product_on_cccp_indx"},
|
data/lib/comee/core/version.rb
CHANGED
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :back_order, class: "Comee::Core::BackOrder" do
|
3
3
|
order_number { Faker::Alphanumeric.alpha(number: 10) }
|
4
4
|
order_date { Date.current }
|
5
|
-
delivery_date { Date.current.advance(
|
5
|
+
delivery_date { Date.current.advance(months: 1) }
|
6
6
|
supplier
|
7
7
|
terms { {payment_terms: "NET 30 days", currency: "Euro", freight_terms: "FOB"} }
|
8
8
|
delivery_address { Faker::Address.full_address }
|
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :sales_order, class: "Comee::Core::SalesOrder" do
|
3
3
|
order_number { Faker::Alphanumeric.alpha(number: 10) }
|
4
4
|
order_date { Date.current }
|
5
|
-
expected_delivery_date { Date.current.advance(
|
5
|
+
expected_delivery_date { Date.current.advance(months: 1) }
|
6
6
|
client
|
7
7
|
client_terms { Faker::Lorem.sentence }
|
8
8
|
payment_no_of_days { 7 }
|
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.18
|
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-10-
|
11
|
+
date: 2023-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|