comee_core 0.1.14 → 0.1.16
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 +2 -2
- data/app/models/comee/core/master_price.rb +1 -1
- data/app/models/comee/core/sales_order.rb +15 -1
- data/db/migrate/20230813235946_create_comee_core_master_prices.rb +4 -1
- data/db/migrate/20230814151601_create_comee_core_client_prices.rb +4 -1
- data/lib/comee/core/version.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: 79192d2994ff3a9aa6f58ed0369421fdf38d7a089dd28a8d88b05664634ad2df
|
4
|
+
data.tar.gz: 59bc3b2bb2c636132602985e5bc165ee17866809522e3137d5dd8c9433972d80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8820af598fd97f4d0755ac480ee05a7c728c954bc316c1e43ddd9db5023233f595836a7181fdf37aed885de0d94869816fc2c0cd7facfd483bddf0b90d4f3ac7
|
7
|
+
data.tar.gz: 6e9b291a3c46742340f05adb192264855291fd3cf39f8ca581d40f1f8e9f66078e485e1e05101a3c5122e551d6cc64e57c83b5f683e5cd83917d059cb2a51382
|
@@ -8,7 +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 :product_id, uniqueness: {scope: :client_id}
|
11
|
+
validates :product_id, uniqueness: {scope: [:client_id, :previous_price_id]}
|
12
12
|
validate :validate_price_validity_dates
|
13
13
|
|
14
14
|
def validate_price_validity_dates
|
@@ -19,7 +19,7 @@ module Comee
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.ransackable_attributes(auth_object = nil)
|
22
|
-
["valid_from", "valid_to", "
|
22
|
+
["valid_from", "valid_to", "price", "status", "product_id", "client_id", "previous_price_id"]
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.ransackable_associations(auth_object = nil)
|
@@ -7,7 +7,7 @@ module Comee
|
|
7
7
|
|
8
8
|
validates :purchase_price, :selling_price, :pp_valid_from, :pp_valid_to, :sp_valid_from, :sp_valid_to, presence: true
|
9
9
|
validates :margin, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
10
|
-
validates :product_id, uniqueness: {scope: :supplier_id}
|
10
|
+
validates :product_id, uniqueness: {scope: [:supplier_id, :previous_price_id]}
|
11
11
|
validate :validate_primary_price, :validate_purchase_price_validity_dates, :validate_selling_price_validity_dates
|
12
12
|
|
13
13
|
def validate_primary_price
|
@@ -4,7 +4,7 @@ module Comee
|
|
4
4
|
belongs_to :client
|
5
5
|
has_many :sales_order_items
|
6
6
|
|
7
|
-
enum :status, {draft: 0, confirmed: 1}
|
7
|
+
enum :status, {draft: 0, confirmed: 1, cancelled: 2}
|
8
8
|
|
9
9
|
validates :order_number, presence: true, uniqueness: true
|
10
10
|
validates :order_date, :expected_delivery_date, :delivery_address, :invoice_address, :status, presence: true
|
@@ -16,6 +16,20 @@ module Comee
|
|
16
16
|
|
17
17
|
delegate(:name, to: :client, prefix: true)
|
18
18
|
|
19
|
+
def confirm
|
20
|
+
raise(StandardError, "Sales order is already confirmed.") if SalesOrder.statuses[status] == SalesOrder.statuses[:confirmed]
|
21
|
+
|
22
|
+
self.status = SalesOrder.statuses[:confirmed]
|
23
|
+
save
|
24
|
+
end
|
25
|
+
|
26
|
+
def cancel
|
27
|
+
raise(StandardError, "Sales order is already cancelled.") if SalesOrder.statuses[status] == SalesOrder.statuses[:cancelled]
|
28
|
+
|
29
|
+
self.status = SalesOrder.statuses[:cancelled]
|
30
|
+
save
|
31
|
+
end
|
32
|
+
|
19
33
|
def self.ransackable_attributes(auth_object = nil)
|
20
34
|
[
|
21
35
|
"delivery_address",
|
@@ -25,6 +25,9 @@ class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
|
|
25
25
|
|
26
26
|
t.timestamps
|
27
27
|
end
|
28
|
-
add_index :comee_core_master_prices,
|
28
|
+
add_index :comee_core_master_prices,
|
29
|
+
[:product_id, :supplier_id, :previous_price_id],
|
30
|
+
unique: true,
|
31
|
+
name: "pi_si_ppi_on_ccmp_indx"
|
29
32
|
end
|
30
33
|
end
|
@@ -20,6 +20,9 @@ class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
20
20
|
|
21
21
|
t.timestamps
|
22
22
|
end
|
23
|
-
add_index :comee_core_client_prices,
|
23
|
+
add_index :comee_core_client_prices,
|
24
|
+
[:product_id, :client_id, :previous_price_id],
|
25
|
+
unique: true,
|
26
|
+
name: "pi_ci_ppi_on_cccp_indx"
|
24
27
|
end
|
25
28
|
end
|
data/lib/comee/core/version.rb
CHANGED
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.16
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|