cats_core 1.3.1 → 1.3.5

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: 6d4aec729abe0584f124c74a2a86fbcfa0d068b6c5b968a847a4a040595e19a8
4
- data.tar.gz: 8b880262cb1ffcb7f92d1e7f2de5039feafac1805f3d9434122abd448c5dc6ea
3
+ metadata.gz: 0c3d4ff631edb9b8c8b84475b5dbc38866a8dc7ee2e6b91d1ae7d0e986ae22c1
4
+ data.tar.gz: ffb3251702f63bba57a7f3c89f960b175b1d341d03ce35468fef4a5b660531e7
5
5
  SHA512:
6
- metadata.gz: 07e042748a002c29d571ec68788ac3ae3369569b41aa60affafeaa0236270bb28a64f5aebb0a48a43eb52b14beb0483b8d72b14f92649d1856b8b77496b53075
7
- data.tar.gz: 387e10b63ecdc87555742a4aad7f505324aa06d569bdf7a7358efc57820886674dd0983673f9fefc5304ed697be276baefef5f63e7961f35134c3d0181f407a6
6
+ metadata.gz: 11f445e39c09484942cd571ec81bf78b23a182dac03f37f89270c359902f75103e2ce0ca0240b9954c5fc580b7af34ac16686d2eaf05ea7dcd9193172abfba60
7
+ data.tar.gz: 9b0dc2b6d6eded7d43aec38c7c9742e4bf10c2f33be48315f172fdb3b278ef697e0e00a2febd5451bb9fbb0d096b2f8977fa2a31fbd7723721813ab5725bd48e
@@ -3,6 +3,11 @@ module Cats
3
3
  class RoutesController < ApplicationController
4
4
  include Common
5
5
 
6
+ def filter
7
+ query = Cats::Core::Route.ransack(params[:q])
8
+ render json: { success: true, data: serialize(query.result) }
9
+ end
10
+
6
11
  private
7
12
 
8
13
  def model_params
@@ -6,7 +6,7 @@ module Cats
6
6
  DONATION_TYPES = [CASH, KIND].freeze
7
7
 
8
8
  belongs_to :donor
9
- belongs_to :plan
9
+ belongs_to :plan, optional: true
10
10
  belongs_to :currency, optional: true
11
11
  belongs_to :commodity_category, optional: true
12
12
  belongs_to :unit_of_measure, optional: true
@@ -1,7 +1,7 @@
1
1
  module Cats
2
2
  module Core
3
3
  class GiftCertificate < ApplicationRecord
4
- belongs_to :donation
4
+ belongs_to :donation, optional: true
5
5
  belongs_to :commodity_category
6
6
  belongs_to :unit_of_measure
7
7
 
@@ -0,0 +1,26 @@
1
+ module Cats
2
+ module Core
3
+ class RegionalRequest < ApplicationRecord
4
+ belongs_to :plan
5
+
6
+ validates :reference_no, presence: true, uniqueness: true
7
+ validates :beneficiaries, :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
8
+ validate :validate_month, :validate_beneficiaries
9
+
10
+ def validate_month
11
+ return unless month
12
+
13
+ errors.add(:month, 'cannot be greater than 12.') if month > 12
14
+ end
15
+
16
+ def validate_beneficiaries
17
+ return unless beneficiaries
18
+
19
+ return unless plan
20
+
21
+ total = plan.plan_items.sum(:beneficiaries)
22
+ errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
23
+ end
24
+ end
25
+ end
26
+ end
@@ -10,6 +10,8 @@ module Cats
10
10
  validates :source_id, uniqueness: { scope: :destination_id }
11
11
  validate :validate_region, :validate_source, :validate_destination
12
12
 
13
+ delegate(:name, to: :region, prefix: true)
14
+
13
15
  def set_name
14
16
  return unless source && destination
15
17
 
@@ -11,6 +11,7 @@ module Cats
11
11
  has_many :transport_bid_items
12
12
  has_many :transport_offers
13
13
  has_many :offer_items, through: :transport_offers
14
+ has_many :tenderers
14
15
  belongs_to :region, class_name: 'Cats::Core::Location', optional: true
15
16
  belongs_to :transport_plan
16
17
 
@@ -1,7 +1,7 @@
1
1
  module Cats
2
2
  module Core
3
3
  class RouteSerializer < ActiveModel::Serializer
4
- attributes :id, :name, :source_id, :destination_id
4
+ attributes :id, :name, :source_id, :destination_id, :region_id, :region_name
5
5
  end
6
6
  end
7
7
  end
data/config/routes.rb CHANGED
@@ -66,6 +66,8 @@ Cats::Core::Engine.routes.draw do
66
66
  end
67
67
  resources :currencies, except: %i[destroy]
68
68
  resources :unit_of_measures, except: %i[destroy]
69
+
70
+ post '/routes/filter', controller: :routes, action: :filter
69
71
  resources :routes, except: %i[destroy]
70
72
 
71
73
  post '/dispatch_plans/filter', controller: :dispatch_plans, action: :filter
@@ -2,6 +2,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_donations do |t|
4
4
  t.string :reference_no, unique: true
5
+ t.string :description
5
6
  t.string :donation_type, null: false
6
7
  t.date :donated_on, null: false
7
8
  t.references :donor,
@@ -9,7 +10,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
9
10
  index: { name: 'donor_on_donation_indx' },
10
11
  foreign_key: { to_table: :cats_core_donors }
11
12
  t.references :plan,
12
- null: false,
13
+ null: true,
13
14
  index: { name: 'plan_on_donation_indx' },
14
15
  foreign_key: { to_table: :cats_core_plans }
15
16
  t.float :amount, null: false
@@ -5,10 +5,10 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
5
5
  t.date :gift_date, null: false
6
6
 
7
7
  t.references :donation,
8
- null: false,
8
+ null: true,
9
9
  index: { name: 'gc_on_donation_indx' },
10
10
  foreign_key: { to_table: :cats_core_donations }
11
-
11
+
12
12
  t.string :vessel
13
13
  t.string :port
14
14
  t.string :customs_declaration_no
@@ -14,6 +14,6 @@ class CreateCatsCoreTransportBidItems < ActiveRecord::Migration[6.1]
14
14
  t.timestamps
15
15
  end
16
16
 
17
- add_index :cats_core_transport_bid_items, :transport_plan_item_id, unique: true
17
+ add_index :cats_core_transport_bid_items, :transport_plan_item_id, unique: true, name: 'tbi_on_tpi_uniq_indx'
18
18
  end
19
19
  end
@@ -0,0 +1,16 @@
1
+ class CreateCatsCoreRegionalRequests < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_regional_requests do |t|
4
+ t.string :reference_no, unique: true
5
+ t.integer :beneficiaries, null: false
6
+ t.integer :month, null: false
7
+ t.integer :no_of_days, null: false
8
+ t.references :plan,
9
+ null: false,
10
+ index: { name: 'plan_on_rr_indx' },
11
+ foreign_key: { to_table: :cats_core_plans }
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.1'.freeze
3
+ VERSION = '1.3.5'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :donation, class: 'Cats::Core::Donation' do
3
3
  reference_no { FFaker::Name.name }
4
+ description { FFaker::Name.name }
4
5
  donation_type { Cats::Core::Donation::KIND }
5
6
  donated_on { Date.today }
6
7
  donor
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :regional_request, class: 'Cats::Core::RegionalRequest' do
3
+ plan do
4
+ pl = create(:plan)
5
+ 3.times { create(:plan_item, plan: pl, beneficiaries: 100) }
6
+ pl
7
+ end
8
+ reference_no { FFaker::Name.name }
9
+ beneficiaries { 100 }
10
+ month { 1 }
11
+ no_of_days { 30 }
12
+ end
13
+ 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.3.1
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-03 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -282,6 +282,7 @@ files:
282
282
  - app/models/cats/core/ration_item.rb
283
283
  - app/models/cats/core/receipt.rb
284
284
  - app/models/cats/core/receipt_transaction.rb
285
+ - app/models/cats/core/regional_request.rb
285
286
  - app/models/cats/core/rhn_request.rb
286
287
  - app/models/cats/core/role.rb
287
288
  - app/models/cats/core/role_menu.rb
@@ -380,6 +381,7 @@ files:
380
381
  - db/migrate/20211229160128_create_cats_core_contract_items.rb
381
382
  - db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
382
383
  - db/migrate/20220103152802_create_cats_core_tenderers.rb
384
+ - db/migrate/20220105084347_create_cats_core_regional_requests.rb
383
385
  - lib/cats/core.rb
384
386
  - lib/cats/core/engine.rb
385
387
  - lib/cats/core/version.rb
@@ -416,6 +418,7 @@ files:
416
418
  - spec/factories/cats/core/rations.rb
417
419
  - spec/factories/cats/core/receipt_transactions.rb
418
420
  - spec/factories/cats/core/receipts.rb
421
+ - spec/factories/cats/core/regional_requests.rb
419
422
  - spec/factories/cats/core/rhn_requests.rb
420
423
  - spec/factories/cats/core/role_menus.rb
421
424
  - spec/factories/cats/core/roles.rb