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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd554c8a5918b912f0d9b2fee535998739a2b7a39192db601992be00fd8d8a8
4
- data.tar.gz: 24693f3a557171aea57c69f95614cc08b59a4b2882c98720d8d028eedc6ba3b9
3
+ metadata.gz: 79192d2994ff3a9aa6f58ed0369421fdf38d7a089dd28a8d88b05664634ad2df
4
+ data.tar.gz: 59bc3b2bb2c636132602985e5bc165ee17866809522e3137d5dd8c9433972d80
5
5
  SHA512:
6
- metadata.gz: cdee0e54cf1f7d7c8ffc5bdba61b980a5548b3f32f240dfd766236f5364e746b7799132826cdbc3d5232f05a810321585cbe0c4f791b60d32fccf7712eef57eb
7
- data.tar.gz: 439c3a1a44b8da1f87485e4892bd6bf1ebf18cd42508616d1f78f48054d2dc4ed30d5ce1f852b8449f7ec0ac76313302ef8fc0d4c97bf005c0af5be8cb30e39f
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", "new_price", "old_price", "product_id", "client_id"]
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, [:product_id, :supplier_id], unique: true
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, [:product_id, :client_id], unique: true
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
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.14"
3
+ VERSION = "0.1.16"
4
4
  end
5
5
  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.14
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-02 00:00:00.000000000 Z
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