cats_core 1.4.32 → 1.4.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/cats/core/commodities_controller.rb +1 -1
- data/app/controllers/cats/core/receipts_controller.rb +2 -1
- data/app/controllers/cats/core/stores_controller.rb +32 -0
- data/app/models/cats/core/commodity.rb +7 -0
- data/app/models/cats/core/receipt.rb +1 -0
- data/app/serializers/cats/core/commodity_serializer.rb +1 -1
- data/app/serializers/cats/core/receipt_serializer.rb +1 -1
- data/app/serializers/cats/core/store_serializer.rb +11 -0
- data/app/services/cats/core/round_plan_service.rb +10 -5
- data/config/routes.rb +5 -0
- data/db/migrate/20210717033223_create_cats_core_commodities.rb +1 -0
- data/db/migrate/20210727105834_create_cats_core_receipts.rb +1 -0
- data/lib/cats/core/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 186d5da451b5abf3212599586408ca925e553e855f185b2ac52038a7cfa7b651
|
4
|
+
data.tar.gz: 7fa1c103c95c8f80d98f75be767bf346b4cb5bfab1cf066776e3ae8880a95621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd85c7c41b4a8c7ab65f388969b4e9e6e5a6191c1eaf19c01bcf6cdbef36018d76136ab73c1bcf57b4fe47f81e5ab6062df1da4ca98970aaec7ddef593818bd7
|
7
|
+
data.tar.gz: 885be8ea62166c70ae4bf3e4f900ed12a18ddecd0b9ba712643e3fe1e781b4099f7e2b8010ca5fdc14ef57089956fe2c43e2de0f36eabe343d69689b13c4b233
|
@@ -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,8 @@ module Cats
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def model_params
|
15
|
-
params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :
|
15
|
+
params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity,
|
16
|
+
:remark)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
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
|
@@ -7,7 +7,7 @@ module Cats
|
|
7
7
|
|
8
8
|
raise(StandardError, 'Plan has no plan items.') if round_plan.round_plan_items.count.zero?
|
9
9
|
|
10
|
-
round_plan.
|
10
|
+
clear_needs(round_plan.id)
|
11
11
|
|
12
12
|
details = []
|
13
13
|
rations = round_plan.round_rations
|
@@ -32,6 +32,13 @@ module Cats
|
|
32
32
|
round_plan
|
33
33
|
end
|
34
34
|
|
35
|
+
def clear_needs(plan_id)
|
36
|
+
Cats::Core::RoundPlanItemDetail
|
37
|
+
.joins(beneficiary_round_plan_item: :round_plan_item)
|
38
|
+
.where(cats_core_beneficiary_round_plan_items: { cats_core_round_plan_items: { round_plan_id: plan_id } })
|
39
|
+
.delete_all
|
40
|
+
end
|
41
|
+
|
35
42
|
def generate_round_plan(reference_no, rounds, plan_id, region_id)
|
36
43
|
round_plan = Cats::Core::RoundPlan.create!(
|
37
44
|
plan_id: plan_id,
|
@@ -48,12 +55,10 @@ module Cats
|
|
48
55
|
quantity: ration.quantity,
|
49
56
|
unit_of_measure_id: ration.unit_of_measure_id,
|
50
57
|
round_plan_id: round_plan.id,
|
51
|
-
no_of_days: ration.no_of_days
|
52
|
-
created_at: Date.today,
|
53
|
-
updated_at: Date.today
|
58
|
+
no_of_days: ration.no_of_days
|
54
59
|
}
|
55
60
|
end
|
56
|
-
Cats::Core::RoundRation.insert_all!(round_rations)
|
61
|
+
Cats::Core::RoundRation.insert_all!(round_rations, record_timestamps: true)
|
57
62
|
plan_items = Cats::Core::PlanItem.where(plan_id: plan_id, region_id: region_id)
|
58
63
|
ben_plan_items = Cats::Core::BeneficiaryPlanItem.where(plan_item: plan_items)
|
59
64
|
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
|
|
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.4.
|
4
|
+
version: 1.4.35
|
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-
|
11
|
+
date: 2022-06-06 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
|