cats_core 1.1.10 → 1.1.14

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: ad7b5e46d923da177a938b7b5728a731a9ce0dc5368bd3c9acae0670a713cbab
4
- data.tar.gz: 07b751a5a1eb18a7a3f9e4f4893ea1b21a9ac74c99c4e975c6fb132861e322b3
3
+ metadata.gz: 849c78b04184a39a42337994d2cf68e4be874dff4e0420e34a890ce0584658cd
4
+ data.tar.gz: 85b1a1ff55a91d353329eaebb38e5ff19bb2590bfa8ab2942dd5feb31a7b11c6
5
5
  SHA512:
6
- metadata.gz: ca48a9753bfcaabe058712978d76f725502f89b3f4cdff386739dc881e3c737dcda23715b0dbb1cbdb7734c85275c5c0c135bb5a53e844a2eb61b4e3a17757eb
7
- data.tar.gz: 2f0626ceca03fd6203818f948b5c98ee94161aa6014df76de98836d1a5d8be6c1939df2b23dc0ae7c8f9a9cd9fc6f59c1e5791f0bc6f776ff35e53494dd547f2
6
+ metadata.gz: 18cb896b37d1c7449e8955e7209bcf663e02b0e43d42fe0c7137f9f8a0e4be5ed1f664d8bc2b2f4e777e15b6f8b6c8efb57114cdb283cdffbc8f51dff6c75d7a
7
+ data.tar.gz: e477156c701bee3b6dfb5c337fb344bcb1e86d16978e0208e8a9616a7721af364ff63862045f85db2ac825dd8fc876b0198ec87f857a4844064cdf7336a8a315
@@ -1,15 +1,20 @@
1
1
  module Cats
2
2
  module Core
3
3
  class UsersController < ApplicationController
4
- before_action :set_user, only: %i[stores warehouses]
4
+ before_action :set_user, only: %i[stores warehouse hub]
5
5
 
6
6
  def stores
7
7
  data = ActiveModelSerializers::SerializableResource.new(@user.stores)
8
8
  render json: { success: true, data: data }
9
9
  end
10
10
 
11
- def warehouses
12
- data = ActiveModelSerializers::SerializableResource.new(@user.warehouses)
11
+ def warehouse
12
+ data = ActiveModelSerializers::SerializableResource.new(@user.warehouse)
13
+ render json: { success: true, data: data }
14
+ end
15
+
16
+ def hub
17
+ data = ActiveModelSerializers::SerializableResource.new(@user.hub)
13
18
  render json: { success: true, data: data }
14
19
  end
15
20
 
@@ -8,6 +8,7 @@ module Cats
8
8
  belongs_to :rhn_request, optional: true
9
9
  belongs_to :commodity
10
10
  belongs_to :source, class_name: 'Cats::Core::Location'
11
+ has_many :allocation_items
11
12
 
12
13
  validates :commodity_status, :allocation_status, presence: true
13
14
  validates :reference_no, presence: true, uniqueness: true
@@ -0,0 +1,8 @@
1
+ module Cats
2
+ module Core
3
+ class NotificationRule < ApplicationRecord
4
+ validates :code, :roles, presence: true
5
+ validates :code, uniqueness: true
6
+ end
7
+ end
8
+ end
@@ -3,8 +3,9 @@ module Cats
3
3
  class RhnRequest < ApplicationRecord
4
4
  belongs_to :commodity
5
5
 
6
- validates :reference_no, :request_date, presence: true
6
+ validates :reference_no, :request_date, :quantity, presence: true
7
7
  validates :reference_no, uniqueness: true
8
+ validates :quantity, numericality: { greater_than: 0 }
8
9
 
9
10
  delegate(:batch_no, to: :commodity, prefix: true)
10
11
  end
@@ -13,10 +13,10 @@ module Cats
13
13
  validates :email, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
14
14
  validate :validate_phone_number
15
15
 
16
- def warehouses
17
- return unless details.key?('warehouses')
16
+ def warehouse
17
+ return unless details.key?('warehouse')
18
18
 
19
- Cats::Core::Location.where(id: details['warehouses'], location_type: Cats::Core::Location::WAREHOUSE)
19
+ Cats::Core::Location.find_by(id: details['warehouse'], location_type: Cats::Core::Location::WAREHOUSE)
20
20
  end
21
21
 
22
22
  def stores
@@ -25,6 +25,12 @@ module Cats
25
25
  Cats::Core::Store.where(id: details['stores'])
26
26
  end
27
27
 
28
+ def hub
29
+ return unless details.key?('hub')
30
+
31
+ Cats::Core::Location.find_by(id: details['hub'], location_type: Cats::Core::Location::HUB)
32
+ end
33
+
28
34
  def validate_phone_number
29
35
  return unless phone_number.present?
30
36
 
data/config/routes.rb CHANGED
@@ -20,7 +20,8 @@ Cats::Core::Engine.routes.draw do
20
20
  resources :users do
21
21
  member do
22
22
  get 'stores', controller: :users, action: :stores
23
- get 'warehouses', controller: :users, action: :warehouses
23
+ get 'warehouse', controller: :users, action: :warehouse
24
+ get 'hub', controller: :users, action: :hub
24
25
  end
25
26
  end
26
27
 
@@ -6,7 +6,7 @@ class CreateCatsCoreUsers < ActiveRecord::Migration[6.1]
6
6
  t.string :email, unique: true
7
7
  t.boolean :active, null: false, default: true
8
8
  t.string :password_digest
9
- t.jsonb :details
9
+ t.jsonb :details, null: false, default: {}
10
10
  t.string :phone_number
11
11
  t.references :application_module,
12
12
  null: false,
@@ -6,6 +6,7 @@ class CreateCatsCoreRhnRequests < ActiveRecord::Migration[6.1]
6
6
  null: false,
7
7
  index: { name: 'commodity_on_rhn_indx' },
8
8
  foreign_key: { to_table: :cats_core_commodities }
9
+ t.float :quantity, null: false
9
10
  t.date :request_date, null: false
10
11
  t.string :requested_by
11
12
 
@@ -0,0 +1,10 @@
1
+ class CreateCatsCoreNotificationRules < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_notification_rules do |t|
4
+ t.string :code, unique: true
5
+ t.string :roles, array: true, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.1.10'.freeze
3
+ VERSION = '1.1.14'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :notification_rule, class: 'Cats::Core::NotificationRule' do
3
+ code { FFaker::Name.name }
4
+ roles { %i[role1 role2] }
5
+ end
6
+ end
@@ -2,6 +2,7 @@ FactoryBot.define do
2
2
  factory :rhn_request, class: 'Cats::Core::RhnRequest' do
3
3
  reference_no { FFaker::Name.name }
4
4
  commodity
5
+ quantity { 100 }
5
6
  request_date { Date.today }
6
7
  requested_by { FFaker::Name.name }
7
8
  end
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.1.10
4
+ version: 1.1.14
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-30 00:00:00.000000000 Z
11
+ date: 2021-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -266,6 +266,7 @@ files:
266
266
  - app/models/cats/core/menu.rb
267
267
  - app/models/cats/core/menu_item.rb
268
268
  - app/models/cats/core/notification.rb
269
+ - app/models/cats/core/notification_rule.rb
269
270
  - app/models/cats/core/operator.rb
270
271
  - app/models/cats/core/program.rb
271
272
  - app/models/cats/core/purchase_order.rb
@@ -339,6 +340,7 @@ files:
339
340
  - db/migrate/20210727074646_create_cats_core_receipts.rb
340
341
  - db/migrate/20210814160628_create_cats_core_receipt_transactions.rb
341
342
  - db/migrate/20210814175406_create_cats_core_stack_transactions.rb
343
+ - db/migrate/20211002050739_create_cats_core_notification_rules.rb
342
344
  - lib/cats/core.rb
343
345
  - lib/cats/core/engine.rb
344
346
  - lib/cats/core/version.rb
@@ -361,6 +363,7 @@ files:
361
363
  - spec/factories/cats/core/locations.rb
362
364
  - spec/factories/cats/core/menu_items.rb
363
365
  - spec/factories/cats/core/menus.rb
366
+ - spec/factories/cats/core/notification_rules.rb
364
367
  - spec/factories/cats/core/notifications.rb
365
368
  - spec/factories/cats/core/operators.rb
366
369
  - spec/factories/cats/core/programs.rb