cats_core 1.0.44 → 1.0.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/allocation.rb +6 -1
- data/app/models/cats/core/dispatch.rb +24 -0
- data/app/models/cats/core/dispatch_transaction.rb +3 -0
- data/app/models/cats/core/store.rb +2 -1
- data/db/migrate/20210717140855_create_cats_core_stores.rb +1 -0
- data/db/migrate/20210718042823_create_cats_core_allocations.rb +1 -0
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +1 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/allocations.rb +1 -0
- data/spec/factories/cats/core/dispatches.rb +1 -0
- data/spec/factories/cats/core/stores.rb +1 -0
- 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: e0cb918631b3c8651aca92abc3209f968ce85fbb0e6408332ae5683b95130333
|
4
|
+
data.tar.gz: 3dca9a7897114e6bf7830951190ac504eaceb03e2f9bf1e3f7de1c5bd1158a5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d658d04da98b1e5607be0843fdfde3663d7ea089b56b9fd7f073420ffa00715613426233c066ca1a92f503bfd8bbc8b9a91663f633ddb93b3e779d1546496a
|
7
|
+
data.tar.gz: 4aa0772c1ca60ec644476785dc96b3fe7639fcb77e2a97d76e6d757f0a44c6a8f8beb6738edd15361e4edeb41c6559f2ae9f6186bd20e601358fcf1cf1092ab9
|
@@ -1,14 +1,19 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Allocation < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
APPROVED = 'Approved'.freeze
|
6
|
+
ALLOCATION_STATUSES = [DRAFT, APPROVED].freeze
|
7
|
+
|
4
8
|
belongs_to :rhn_request, optional: true
|
5
9
|
belongs_to :commodity
|
6
10
|
belongs_to :source, class_name: 'Cats::Core::Location'
|
7
11
|
|
8
|
-
validates :commodity_status, presence: true
|
12
|
+
validates :commodity_status, :allocation_status, presence: true
|
9
13
|
validates :reference_no, presence: true, uniqueness: true
|
10
14
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
11
15
|
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
16
|
+
validates :allocation_status, inclusion: { in: ALLOCATION_STATUSES }
|
12
17
|
|
13
18
|
delegate(:reference_no, to: :rhn_request, prefix: :rhn, allow_nil: true)
|
14
19
|
delegate(:batch_no, to: :commodity, prefix: true)
|
@@ -1,14 +1,38 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Dispatch < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
APPROVED = 'Approved'.freeze
|
6
|
+
STARTED = 'Started'.freeze
|
7
|
+
ARRIVED = 'Arrived'.freeze
|
8
|
+
UNLOADED = 'Unloaded'.freeze
|
9
|
+
RECEIVED = 'Received'.freeze
|
10
|
+
|
11
|
+
DISPATCH_STATUSES = [DRAFT, APPROVED, STARTED, ARRIVED, UNLOADED, RECEIVED].freeze
|
12
|
+
|
4
13
|
belongs_to :prepared_by, class_name: 'Cats::Core::User'
|
5
14
|
belongs_to :transporter
|
6
15
|
belongs_to :allocation_item
|
7
16
|
|
8
17
|
validates :reference_no, :plate_no, :driver_name, :driver_phone, :quantity, :commodity_status, presence: true
|
18
|
+
validates :dispatch_status, presence: true, inclusion: { in: DISPATCH_STATUSES }
|
9
19
|
validates :reference_no, uniqueness: true
|
10
20
|
validates :quantity, numericality: { greater_than: 0 }
|
11
21
|
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
22
|
+
validate :validate_quantity
|
23
|
+
|
24
|
+
delegate(:name, to: :transporter, prefix: true)
|
25
|
+
delegate(:email, to: :prepared_by, prefix: true)
|
26
|
+
|
27
|
+
def validate_quantity
|
28
|
+
return unless quantity && allocation_item
|
29
|
+
|
30
|
+
return unless quantity_changed?
|
31
|
+
|
32
|
+
dispatched = Dispatch.where(allocation_item: allocation_item).sum(:quantity)
|
33
|
+
remaining = allocation_item.quantity - dispatched
|
34
|
+
errors.add(:quantity, "exceeds allocated quantity. Maximum allowed is #{remaining}") if quantity > remaining
|
35
|
+
end
|
12
36
|
end
|
13
37
|
end
|
14
38
|
end
|
@@ -3,6 +3,9 @@ module Cats
|
|
3
3
|
class DispatchTransaction < Transaction
|
4
4
|
belongs_to :source, class_name: 'Cats::Core::Stack'
|
5
5
|
belongs_to :destination, class_name: 'Cats::Core::Dispatch'
|
6
|
+
|
7
|
+
delegate(:code, to: :source, prefix: true)
|
8
|
+
delegate(:reference_no, to: :destination, prefix: true)
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
@@ -5,7 +5,8 @@ module Cats
|
|
5
5
|
belongs_to :store_keeper, class_name: 'Cats::Core::User'
|
6
6
|
has_many :stacks
|
7
7
|
|
8
|
-
validates :name, :length, :width, :height, presence: true
|
8
|
+
validates :code, :name, :length, :width, :height, presence: true
|
9
|
+
validates :code, uniqueness: true
|
9
10
|
validates :length, :width, :height, numericality: { greater_than: 0 }
|
10
11
|
validates :gangway_length, :gangway_width, :gangway_corner_dist, presence: true, if: :has_gangway?
|
11
12
|
validates :gangway_length,
|
@@ -16,6 +16,7 @@ class CreateCatsCoreAllocations < ActiveRecord::Migration[6.1]
|
|
16
16
|
foreign_key: { to_table: :cats_core_locations }
|
17
17
|
t.float :quantity, null: false
|
18
18
|
t.string :commodity_status, null: false, default: 'Good'
|
19
|
+
t.string :allocation_status, null: false, default: 'Draft'
|
19
20
|
t.string :remark
|
20
21
|
|
21
22
|
t.timestamps
|
data/lib/cats/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|