cats_core 1.2.39 → 1.3.2

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: 2dd8f771f3ee41bb9c72fc0eece0531aaca3eb3a1fc9722859b67d2eb8b5ef59
4
- data.tar.gz: 3881439fd98966fde7d3261354f65a18348424ef1732193e4250763cca938517
3
+ metadata.gz: 2a6a1ea34a4402faf06a312e6fddc4ce4809df7d509a598b6802e5ac639102ef
4
+ data.tar.gz: a65237debf4b93fa53881922294caca38b7cd8079fd43a4d92d7cb072c2fa080
5
5
  SHA512:
6
- metadata.gz: d558bbbfb5ae14033312066581de38f6e8dceec258002c72f03b8aec8194d22968efcf47372b5ea7446e63b71fed229d57ce0af11b21453af73f6a39863734c0
7
- data.tar.gz: fe6eeec34ae2d998d41eff5631c626467162b5592045aa744c6fd0b83587350372b592d57f522dd058359ef00fcb92c754d2ee33ff077c4d3d01d39259a84745
6
+ metadata.gz: 6190f8e0a5cbb726cd0c06bcd7382683be8b570c9e6827d55791c9d949258c29a22b6a5b4a2918835e71d4d273df9e35796cc9ebed636a91e871ccefdba385a9
7
+ data.tar.gz: ba4af2345cadf310c41a1b77345bc28fa877ee5b4c258ee0a89db3ec2c43316cdb7373a067dbe82f5bceb74e5e8a91f6491415bb27a7a16b4f7b0798234f4d6f
@@ -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
@@ -8,6 +8,8 @@ module Cats
8
8
  validates :rank, numericality: { greater_than: 0 }, allow_nil: true
9
9
  validate :validate_rank_is_set_for_winner
10
10
 
11
+ delegate(:route, to: :transport_bid_item)
12
+
11
13
  def mark_as_winner(rank)
12
14
  raise(StandardError, 'Offer item already marked as winner.') if winner
13
15
 
@@ -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
 
@@ -0,0 +1,13 @@
1
+ module Cats
2
+ module Core
3
+ class Tenderer < ApplicationRecord
4
+ belongs_to :transport_bid
5
+ belongs_to :transporter
6
+
7
+ validates :purchased_by, :phone_no, presence: true
8
+
9
+ delegate(:reference_no, to: :transport_bid)
10
+ delegate(:name, to: :transporter, prefix: true)
11
+ end
12
+ end
13
+ end
@@ -10,6 +10,10 @@ module Cats
10
10
  validates :transport_plan_item_id, uniqueness: true
11
11
 
12
12
  delegate(:reference_no, to: :transport_bid, prefix: true)
13
+
14
+ def route
15
+ transport_plan_item.route.name
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -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
@@ -0,0 +1,18 @@
1
+ class CreateCatsCoreTenderers < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_tenderers do |t|
4
+ t.references :transport_bid,
5
+ null: false,
6
+ index: { name: 'tb_on_tenderer_indx' },
7
+ foreign_key: { to_table: :cats_core_transport_bids }
8
+ t.references :transporter,
9
+ null: false,
10
+ index: { name: 'transporter_on_tenderer_indx' },
11
+ foreign_key: { to_table: :cats_core_transporters }
12
+ t.string :purchased_by, null: false
13
+ t.string :phone_no, null: false
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.39'.freeze
3
+ VERSION = '1.3.2'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :tenderer, class: 'Cats::Core::Tenderer' do
3
+ transport_bid
4
+ transporter
5
+ purchased_by { FFaker::Name.name }
6
+ phone_no { FFaker::Name.name }
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.39
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
@@ -291,6 +291,7 @@ files:
291
291
  - app/models/cats/core/stacking_rule.rb
292
292
  - app/models/cats/core/store.rb
293
293
  - app/models/cats/core/supplier.rb
294
+ - app/models/cats/core/tenderer.rb
294
295
  - app/models/cats/core/transaction.rb
295
296
  - app/models/cats/core/transport_bid.rb
296
297
  - app/models/cats/core/transport_bid_item.rb
@@ -378,6 +379,7 @@ files:
378
379
  - db/migrate/20211229160127_create_cats_core_transport_contracts.rb
379
380
  - db/migrate/20211229160128_create_cats_core_contract_items.rb
380
381
  - db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
382
+ - db/migrate/20220103152802_create_cats_core_tenderers.rb
381
383
  - lib/cats/core.rb
382
384
  - lib/cats/core/engine.rb
383
385
  - lib/cats/core/version.rb
@@ -423,6 +425,7 @@ files:
423
425
  - spec/factories/cats/core/stacks.rb
424
426
  - spec/factories/cats/core/stores.rb
425
427
  - spec/factories/cats/core/suppliers.rb
428
+ - spec/factories/cats/core/tenderers.rb
426
429
  - spec/factories/cats/core/transport_bid_items.rb
427
430
  - spec/factories/cats/core/transport_bids.rb
428
431
  - spec/factories/cats/core/transport_contracts.rb