cats_core 1.4.32 → 1.4.33

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: 44499bfd42e79fe95a119690cd54c9adbe2e43a3307f80ae97c5f18f33676818
4
- data.tar.gz: 8ff508a01a4da75b991c0f1e4da6f4b3cfe15760a62fee0bcaeee4ea37f31e8b
3
+ metadata.gz: e34b55e4d9cc5537027134594fd2f39946cd9b1001ab3a3d20c24109402a7797
4
+ data.tar.gz: 2437a6f18cab7ce976653738467dd0849182281f2fb1e5b2e832390538adf112
5
5
  SHA512:
6
- metadata.gz: 226ca5049ebb2542a12558e405548a8e72dcdd141085fc1627f08c7e531c13322d5ec4d652ee3df1081d82ff4a8f5cdb7ba01b18286e922189bf10aca675351c
7
- data.tar.gz: 1558e359924f5260e962096083c98343d590beab1747d6b07ee0fdde47a0b14eb39e86b6a114569371694757fda494c63018f16c3d3f9c5fe12e523aa5462557
6
+ metadata.gz: a574e2522a5d9c2ba8257ee18c5217023c23e7b6f5d69dddd9dc0d81f9169a697afc6fde167f4b41a36fd861f78abc7a3b3ad156859a1e49dc1bf412dab771e4
7
+ data.tar.gz: f1d30af5df117fb71047df56a7602024df16270e2531c94e65acf1f77e58fe56f3a895e64c14d6629ae88ce0b48f1a4aa3e3095c2bb5872cda31d44ad0c52a16
@@ -19,7 +19,7 @@ module Cats
19
19
  private
20
20
 
21
21
  def model_params
22
- params.require(:payload).permit(:batch_no, :description, :unit_of_measure_id, :source_id,
22
+ params.require(:payload).permit(:batch_no, :description, :unit_of_measure_id, :source_id, :commodity_grade,
23
23
  :source_type, :quantity, :best_use_before, :volume_per_metric_ton,
24
24
  :arrival_status, :shipping_reference)
25
25
  end
@@ -12,7 +12,7 @@ module Cats
12
12
  private
13
13
 
14
14
  def model_params
15
- params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :quantity, :remark)
15
+ params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark)
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,32 @@
1
+ module Cats
2
+ module Core
3
+ class StoresController < ApplicationController
4
+ include Common
5
+
6
+ def index
7
+ stores = Cats::Core::Store.where(warehouse_id: params[:id])
8
+ render json: { success: true, data: serialize(stores) }
9
+ end
10
+
11
+ def filter
12
+ query = Store.ransack(params[:q])
13
+ render json: { success: true, data: serialize(query.result) }
14
+ end
15
+
16
+ def stores_for_hub
17
+ warehouses = Cats::Core::Location.find(params[:id]).children
18
+ ids = warehouses.map(&:id)
19
+ stores = Cats::Core::Store.where(warehouse_id: ids)
20
+ render json: { success: true, data: serialize(stores) }
21
+ end
22
+
23
+ private
24
+
25
+ def model_params
26
+ params.require('payload').permit(:id, :code, :name, :length, :width, :height, :temporary, :has_gangway,
27
+ :gangway_length, :gangway_width, :gangway_corner_dist, :warehouse_id,
28
+ :store_keeper_id)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,6 +7,12 @@ module Cats
7
7
  ALLOCATED = 'Allocated'.freeze
8
8
  STATUSES = [DRAFT, APPROVED, ALLOCATED].freeze
9
9
 
10
+ # Grades
11
+ GRADE1 = 'Grade1'.freeze
12
+ GRADE2 = 'Grade2'.freeze
13
+ GRADE3 = 'Grade3'.freeze
14
+ COMMODITY_GRADES = [GRADE1, GRADE2, GRADE3].freeze
15
+
10
16
  # Commodity statuses
11
17
  GOOD = 'Good'.freeze
12
18
  DAMAGED = 'Damaged'.freeze
@@ -37,6 +43,7 @@ module Cats
37
43
  validates :volume_per_metric_ton, numericality: { greater_than: 0, allow_nil: true }
38
44
  validates :arrival_status, presence: true, inclusion: { in: ARRIVAL_STATUSES }
39
45
  validates :status, presence: true, inclusion: { in: STATUSES }
46
+ validates :commodity_grade, inclusion: { in: COMMODITY_GRADES }, allow_nil: true
40
47
  validate :validate_updateability, on: :update
41
48
 
42
49
  delegate(:abbreviation, to: :unit_of_measure, prefix: 'unit')
@@ -4,6 +4,7 @@ module Cats
4
4
  belongs_to :receipt_authorization
5
5
 
6
6
  validates :commodity_status, presence: true, inclusion: { in: Commodity::COMMODITY_STATUSES }
7
+ validates :commodity_grade, inclusion: { in: Commodity::COMMODITY_GRADES }, allow_nil: true
7
8
  validates :quantity, presence: true, numericality: { greater_than: 0 }
8
9
  end
9
10
  end
@@ -3,7 +3,7 @@ module Cats
3
3
  class CommoditySerializer < ActiveModel::Serializer
4
4
  attributes :id, :name, :batch_no, :description, :unit_of_measure_id, :unit_abbreviation, :source_id,
5
5
  :source_type, :source_reference_no, :quantity, :best_use_before, :volume_per_metric_ton,
6
- :arrival_status, :status, :shipping_reference
6
+ :arrival_status, :status, :shipping_reference, :commodity_grade
7
7
  end
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  module Cats
2
2
  module Core
3
3
  class ReceiptSerializer < ActiveModel::Serializer
4
- attributes :id, :receipt_authorization_id, :commodity_status, :quantity, :remark
4
+ attributes :id, :receipt_authorization_id, :commodity_status, :commodity_grade, :quantity, :remark
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,11 @@
1
+ module Cats
2
+ module Core
3
+ class StoreSerializer < ActiveModel::Serializer
4
+ attributes :id, :code, :name, :store_keeper_name, :store_keeper_phone_number, :length, :width, :height,
5
+ :temporary, :has_gangway, :gangway_length, :gangway_width, :gangway_corner_dist, :warehouse_id,
6
+ :store_keeper_id
7
+
8
+ has_many :stacks
9
+ end
10
+ end
11
+ end
@@ -48,12 +48,10 @@ module Cats
48
48
  quantity: ration.quantity,
49
49
  unit_of_measure_id: ration.unit_of_measure_id,
50
50
  round_plan_id: round_plan.id,
51
- no_of_days: ration.no_of_days,
52
- created_at: Date.today,
53
- updated_at: Date.today
51
+ no_of_days: ration.no_of_days
54
52
  }
55
53
  end
56
- Cats::Core::RoundRation.insert_all!(round_rations)
54
+ Cats::Core::RoundRation.insert_all!(round_rations, record_timestamps: true)
57
55
  plan_items = Cats::Core::PlanItem.where(plan_id: plan_id, region_id: region_id)
58
56
  ben_plan_items = Cats::Core::BeneficiaryPlanItem.where(plan_item: plan_items)
59
57
  round_plan_items = plan_items.map do |plan_item|
data/config/routes.rb CHANGED
@@ -169,4 +169,9 @@ Cats::Core::Engine.routes.draw do
169
169
  get '/receipts/:id/stacks', controller: :stacks, action: :receipt_stacks, as: :receipt_stacks
170
170
  get '/dispatches/:id/stacks', controller: :stacks, action: :dispatch_stacks, as: :dispatch_stacks
171
171
  resources :stacks, only: %i[show index create update]
172
+
173
+ get '/warehouses/:id/stores', controller: :stores, action: :index, as: :stores_warehouse
174
+ get '/hubs/:id/stores', controller: :stores, action: :stores_for_hub, as: :stores_hub
175
+ resources :stores, only: %i[index show create update]
176
+ post '/stores/filter', controller: :stores, action: :filter
172
177
  end
@@ -14,6 +14,7 @@ class CreateCatsCoreCommodities < ActiveRecord::Migration[6.1]
14
14
  t.string :arrival_status, null: false, default: 'At Source'
15
15
  t.boolean :approved, null: false, default: false
16
16
  t.string :shipping_reference
17
+ t.string :commodity_grade
17
18
 
18
19
  t.timestamps
19
20
  end
@@ -6,6 +6,7 @@ class CreateCatsCoreReceipts < ActiveRecord::Migration[7.0]
6
6
  index: { name: 'ra_on_receipts_indx' },
7
7
  foreign_key: { to_table: :cats_core_receipt_authorizations }
8
8
  t.string :commodity_status, null: false
9
+ t.string :commodity_grade
9
10
  t.float :quantity, null: false
10
11
  t.string :remark
11
12
 
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.4.32'.freeze
3
+ VERSION = '1.4.33'.freeze
4
4
  end
5
5
  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.4.32
4
+ version: 1.4.33
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-06-02 00:00:00.000000000 Z
11
+ date: 2022-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -252,6 +252,7 @@ files:
252
252
  - app/controllers/cats/core/routes_controller.rb
253
253
  - app/controllers/cats/core/spaces_controller.rb
254
254
  - app/controllers/cats/core/stacks_controller.rb
255
+ - app/controllers/cats/core/stores_controller.rb
255
256
  - app/controllers/cats/core/transporters_controller.rb
256
257
  - app/controllers/cats/core/unit_conversions_controller.rb
257
258
  - app/controllers/cats/core/unit_of_measures_controller.rb
@@ -348,6 +349,7 @@ files:
348
349
  - app/serializers/cats/core/round_plan_serializer.rb
349
350
  - app/serializers/cats/core/route_serializer.rb
350
351
  - app/serializers/cats/core/stack_serializer.rb
352
+ - app/serializers/cats/core/store_serializer.rb
351
353
  - app/serializers/cats/core/transporter_serializer.rb
352
354
  - app/serializers/cats/core/unit_conversion_serializer.rb
353
355
  - app/serializers/cats/core/unit_of_measure_serializer.rb