cats_core 1.4.44 → 1.4.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cats/core/dispatch_plans_controller.rb +1 -1
- data/app/controllers/cats/core/dispatch_transactions_controller.rb +5 -0
- data/app/controllers/cats/core/loans_controller.rb +2 -2
- data/app/controllers/cats/core/locations_controller.rb +11 -0
- data/app/controllers/cats/core/purchase_orders_controller.rb +1 -1
- data/app/controllers/cats/core/receipt_transactions_controller.rb +5 -0
- data/app/controllers/cats/core/stores_controller.rb +36 -5
- data/app/controllers/cats/core/swaps_controller.rb +3 -3
- data/app/models/cats/core/commodity.rb +1 -1
- data/app/models/cats/core/commodity_donation.rb +4 -0
- data/app/models/cats/core/dispatch.rb +15 -0
- data/app/models/cats/core/loan.rb +4 -0
- data/app/models/cats/core/location.rb +9 -5
- data/app/models/cats/core/purchase_order.rb +4 -0
- data/app/models/cats/core/stack.rb +2 -1
- data/app/models/cats/core/store.rb +0 -24
- data/app/models/cats/core/swap.rb +4 -0
- data/app/serializers/cats/core/store_serializer.rb +2 -3
- data/app/services/cats/core/authorization_service.rb +50 -0
- data/app/services/cats/core/location_service.rb +25 -0
- data/config/routes.rb +20 -1
- data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +1 -0
- data/db/migrate/20210717140855_create_cats_core_stores.rb +1 -4
- data/db/migrate/20220626063501_create_cats_core_loans.rb +1 -0
- data/db/migrate/20220626063757_create_cats_core_swaps.rb +1 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_plan_items.rb +1 -1
- data/spec/factories/cats/core/loans.rb +1 -0
- data/spec/factories/cats/core/locations.rb +9 -0
- data/spec/factories/cats/core/purchase_orders.rb +1 -0
- data/spec/factories/cats/core/stores.rb +0 -2
- data/spec/factories/cats/core/swaps.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cd51ff40bb6a3dc2aa226e29abbcec7fe47e833095bfabfefbe6e32d4d15a28
|
4
|
+
data.tar.gz: 05726c3a11c58983b9360d9ff8cf4384927148cc67d825e9b21114c823c07e78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea7b46396f1f5ab18cb30d0fbacaa2275f72840fd0fa0d27a0e33cab49be523eb2ddcaa5747d15bb3a5a9120987cf59ee2cae402f2d0e282d6fe72d115f7ac3
|
7
|
+
data.tar.gz: f7a48bf8792e57e5580a44e471a5efbf6e5a66aace12eb5b648685e7105e56b295c218ea6c7f4ad96cb31edadbe568245a3c781b16c1b483a120f777c55bee7b
|
@@ -12,8 +12,8 @@ module Cats
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def model_params
|
15
|
-
params.require(:payload).permit(:reference_no, :lender, :agreement_date, :repayment_date,
|
16
|
-
:commodity_category_id)
|
15
|
+
params.require(:payload).permit(:reference_no, :description, :lender, :agreement_date, :repayment_date,
|
16
|
+
:quantity, :unit_id, :commodity_category_id)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -25,11 +25,22 @@ module Cats
|
|
25
25
|
render json: { success: true, data: serialize(woredas) }
|
26
26
|
end
|
27
27
|
|
28
|
+
def create_fdp
|
29
|
+
service = LocationService.new
|
30
|
+
p = fdp_params
|
31
|
+
fdp = service.create_fdp(p[:code], p[:name], p[:parent_id], p[:description])
|
32
|
+
render json: { success: true, data: serialize(fdp) }
|
33
|
+
end
|
34
|
+
|
28
35
|
private
|
29
36
|
|
30
37
|
def model_params
|
31
38
|
params.require(:payload).permit(:code, :name, :location_type, :description, :parent_id)
|
32
39
|
end
|
40
|
+
|
41
|
+
def fdp_params
|
42
|
+
params.require(:payload).permit(:code, :name, :description, :parent_id)
|
43
|
+
end
|
33
44
|
end
|
34
45
|
end
|
35
46
|
end
|
@@ -17,7 +17,7 @@ module Cats
|
|
17
17
|
def model_params
|
18
18
|
params.require(:payload).permit(:reference_no, :order_date, :requisition_no, :supplier, :cash_donation_id,
|
19
19
|
:commodity_category_id, :quantity, :purchase_type, :unit_id, :price,
|
20
|
-
:currency_id)
|
20
|
+
:currency_id, :description)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -4,28 +4,59 @@ module Cats
|
|
4
4
|
include Common
|
5
5
|
|
6
6
|
def index
|
7
|
-
stores = Store.includes(:
|
7
|
+
stores = Store.includes(:stacks).where(warehouse_id: params[:id])
|
8
8
|
render json: { success: true, data: serialize(stores) }
|
9
9
|
end
|
10
10
|
|
11
11
|
def filter
|
12
|
-
query = Store.includes(:
|
12
|
+
query = Store.includes(:stacks).ransack(params[:q])
|
13
13
|
render json: { success: true, data: serialize(query.result) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def stores_for_hub
|
17
17
|
warehouses = Location.find(params[:id]).children
|
18
18
|
ids = warehouses.map(&:id)
|
19
|
-
stores = Store.includes(:
|
19
|
+
stores = Store.includes(:stacks).where(warehouse_id: ids)
|
20
20
|
render json: { success: true, data: serialize(stores) }
|
21
21
|
end
|
22
22
|
|
23
|
+
def assign_store
|
24
|
+
store_keeper = User.find(params[:id])
|
25
|
+
store_keeper.details['stores'] ||= []
|
26
|
+
store_keeper.details['stores'] += store_params[:store_ids]
|
27
|
+
store_keeper.save!
|
28
|
+
render json: { success: true, data: serialize(store_keeper) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def unassign_store
|
32
|
+
store_keeper = User.find(params[:id])
|
33
|
+
if store_keeper.details.key?('stores')
|
34
|
+
store_keeper.details['stores'] -= store_params[:store_ids]
|
35
|
+
render json: { success: true, data: serialize(store_keeper) }
|
36
|
+
else
|
37
|
+
render json: { success: false, error: 'User has no stores assigned.' }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def fdp
|
42
|
+
store = Store.find(params[:id])
|
43
|
+
location = store.warehouse.parent
|
44
|
+
if location.location_type == Location::FDP
|
45
|
+
render json: { success: true, data: serialize(location) }
|
46
|
+
else
|
47
|
+
render json: { success: false, error: 'No FDP is associated with store.' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
23
51
|
private
|
24
52
|
|
25
53
|
def model_params
|
26
54
|
params.require('payload').permit(:id, :code, :name, :length, :width, :height, :temporary, :has_gangway,
|
27
|
-
:gangway_length, :gangway_width, :gangway_corner_dist, :warehouse_id
|
28
|
-
|
55
|
+
:gangway_length, :gangway_width, :gangway_corner_dist, :warehouse_id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def store_params
|
59
|
+
params.require(:payload).permit(store_ids: [])
|
29
60
|
end
|
30
61
|
end
|
31
62
|
end
|
@@ -12,9 +12,9 @@ module Cats
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def model_params
|
15
|
-
params.require(:payload).permit(:reference_no, :swapper, :agreement_date, :issued_commodity_id,
|
16
|
-
:issued_quantity, :received_commodity_id, :received_quantity,
|
17
|
-
:
|
15
|
+
params.require(:payload).permit(:reference_no, :swapper, :agreement_date, :issued_commodity_id, :description,
|
16
|
+
:issued_quantity, :received_commodity_id, :received_quantity, :issued_unit_id,
|
17
|
+
:received_unit_id)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -60,7 +60,7 @@ module Cats
|
|
60
60
|
def name
|
61
61
|
# For this to be efficient, our query should use includes like
|
62
62
|
# Commodity.includes(project: { source: commodity_category })
|
63
|
-
project.source.
|
63
|
+
project.source.commodity_name
|
64
64
|
end
|
65
65
|
|
66
66
|
def validate_updateability
|
@@ -10,6 +10,10 @@ module Cats
|
|
10
10
|
delegate(:reference_no, to: :plan, prefix: true, allow_nil: true)
|
11
11
|
delegate(:name, to: :commodity_category, prefix: true)
|
12
12
|
delegate(:abbreviation, to: :unit, prefix: true)
|
13
|
+
|
14
|
+
def commodity_name
|
15
|
+
commodity_category.name
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -75,6 +75,21 @@ module Cats
|
|
75
75
|
def start
|
76
76
|
self.dispatch_status = STARTED
|
77
77
|
save!
|
78
|
+
|
79
|
+
# Check if destination is an FDP and create receipt authorization
|
80
|
+
location = dispatch_plan_item.destination
|
81
|
+
authorized_by = User.find_by(first_name: 'SYSTEM-USER')
|
82
|
+
return unless location.location_type == Location::FDP
|
83
|
+
|
84
|
+
store = location.fdp_store
|
85
|
+
ReceiptAuthorization.create!(
|
86
|
+
dispatch: self,
|
87
|
+
store: store,
|
88
|
+
quantity: quantity,
|
89
|
+
received_quantity: 0,
|
90
|
+
status: Authorization::AUTHORIZED,
|
91
|
+
authorized_by: authorized_by
|
92
|
+
)
|
78
93
|
end
|
79
94
|
|
80
95
|
def receive
|
@@ -5,11 +5,10 @@ module Cats
|
|
5
5
|
ZONE = 'Zone'.freeze
|
6
6
|
WOREDA = 'Woreda'.freeze
|
7
7
|
FDP = 'Fdp'.freeze
|
8
|
-
KEBELE = 'Kebele'.freeze
|
9
8
|
HUB = 'Hub'.freeze
|
10
9
|
WAREHOUSE = 'Warehouse'.freeze
|
11
10
|
|
12
|
-
LOCATION_TYPES = [REGION, ZONE, WOREDA,
|
11
|
+
LOCATION_TYPES = [REGION, ZONE, WOREDA, FDP, HUB, WAREHOUSE].freeze
|
13
12
|
|
14
13
|
has_ancestry
|
15
14
|
|
@@ -23,10 +22,9 @@ module Cats
|
|
23
22
|
REGION => [],
|
24
23
|
ZONE => [REGION],
|
25
24
|
WOREDA => [REGION, ZONE],
|
26
|
-
KEBELE => [REGION, ZONE, WOREDA],
|
27
25
|
FDP => [REGION, ZONE, WOREDA],
|
28
|
-
HUB => [REGION, ZONE, WOREDA,
|
29
|
-
WAREHOUSE => [REGION, ZONE, WOREDA,
|
26
|
+
HUB => [REGION, ZONE, WOREDA, FDP],
|
27
|
+
WAREHOUSE => [REGION, ZONE, WOREDA, FDP, HUB]
|
30
28
|
}
|
31
29
|
|
32
30
|
return if location_type.nil? || location_type.empty?
|
@@ -46,6 +44,12 @@ module Cats
|
|
46
44
|
# wrong type of parent to our location.
|
47
45
|
errors.add(:location, "cannot have #{parent.location_type} as parent")
|
48
46
|
end
|
47
|
+
|
48
|
+
def fdp_store
|
49
|
+
return nil unless location_type == FDP
|
50
|
+
|
51
|
+
Store.find_by(code: "FDP-ST-#{code}")
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -21,7 +21,8 @@ module Cats
|
|
21
21
|
validates :stack_status, inclusion: { in: STACK_STATUSES }
|
22
22
|
validate :validate_coordinates, :validate_dimensions, :validate_distance_from_wall, :validate_overlap,
|
23
23
|
:validate_space_between_stack, :validate_max_height, :validate_max_length, :validate_max_width,
|
24
|
-
:validate_distance_from_ceiling,
|
24
|
+
:validate_distance_from_ceiling,
|
25
|
+
unless: -> { store && (store.code == 'SUP-STORE' || store.code.start_with?('FDP-ST')) }
|
25
26
|
|
26
27
|
delegate :batch_no, to: :commodity, prefix: true
|
27
28
|
|
@@ -2,7 +2,6 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class Store < ApplicationRecord
|
4
4
|
belongs_to :warehouse, class_name: 'Cats::Core::Location'
|
5
|
-
belongs_to :store_keeper, class_name: 'Cats::Core::User'
|
6
5
|
has_many :stacks
|
7
6
|
|
8
7
|
validates :code, :name, :length, :width, :height, presence: true
|
@@ -17,7 +16,6 @@ module Cats
|
|
17
16
|
validate :validate_location
|
18
17
|
|
19
18
|
before_create :update_usable_space
|
20
|
-
after_save :update_store_keeper
|
21
19
|
|
22
20
|
def validate_location
|
23
21
|
return if warehouse.nil?
|
@@ -25,33 +23,11 @@ module Cats
|
|
25
23
|
errors.add(:warehouse, 'must be a valid warehouse') unless warehouse.location_type == Location::WAREHOUSE
|
26
24
|
end
|
27
25
|
|
28
|
-
def store_keeper_name
|
29
|
-
"#{store_keeper.first_name} #{store_keeper.last_name}"
|
30
|
-
end
|
31
|
-
|
32
26
|
def update_usable_space
|
33
27
|
self.usable_space = (length - 2) * (width - 2)
|
34
28
|
self.usable_space -= (gangway_length * gangway_width) if has_gangway
|
35
29
|
self.available_space = self.usable_space
|
36
30
|
end
|
37
|
-
|
38
|
-
def update_store_keeper
|
39
|
-
return unless store_keeper_id_previously_changed?
|
40
|
-
|
41
|
-
unless id_previously_changed?
|
42
|
-
old_storekeeper = Cats::Core::User.find(store_keeper_id_previously_was)
|
43
|
-
old_storekeeper.details['stores'].delete(id)
|
44
|
-
old_storekeeper.save
|
45
|
-
end
|
46
|
-
if store_keeper.details.key?('stores')
|
47
|
-
store_keeper.details['stores'] << id
|
48
|
-
else
|
49
|
-
store_keeper.details['stores'] = [id]
|
50
|
-
end
|
51
|
-
store_keeper.save
|
52
|
-
end
|
53
|
-
|
54
|
-
delegate(:phone_number, to: :store_keeper, prefix: true)
|
55
31
|
end
|
56
32
|
end
|
57
33
|
end
|
@@ -14,6 +14,10 @@ module Cats
|
|
14
14
|
delegate(:name, to: :received_commodity, prefix: true)
|
15
15
|
delegate(:abbreviation, to: :issued_unit, prefix: true)
|
16
16
|
delegate(:abbreviation, to: :received_unit, prefix: true)
|
17
|
+
|
18
|
+
def commodity_name
|
19
|
+
received_commodity.name
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class StoreSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :code, :name, :
|
5
|
-
:
|
6
|
-
:store_keeper_id
|
4
|
+
attributes :id, :code, :name, :length, :width, :height, :temporary, :has_gangway, :gangway_length,
|
5
|
+
:gangway_width, :gangway_corner_dist, :warehouse_id
|
7
6
|
|
8
7
|
has_many :stacks
|
9
8
|
end
|
@@ -24,9 +24,42 @@ module Cats
|
|
24
24
|
statuses = authorization.dispatch.receipt_authorizations.map(&:driver_confirmed).uniq
|
25
25
|
authorization.dispatch.receive if statuses.length == 1 && statuses[0]
|
26
26
|
|
27
|
+
# Create destination stack and transaction for FDP
|
28
|
+
location = authorization.dispatch.dispatch_plan_item.destination
|
29
|
+
if location.location_type == Location::FDP
|
30
|
+
create_stack(authorization_id)
|
31
|
+
stack(authorization_id)
|
32
|
+
end
|
33
|
+
|
27
34
|
authorization
|
28
35
|
end
|
29
36
|
|
37
|
+
# A method to create stack and stack transactions for FDP
|
38
|
+
def create_stack(authorization_id)
|
39
|
+
authorization = ReceiptAuthorization.find(authorization_id)
|
40
|
+
commodity = authorization.dispatch.dispatch_plan_item.commodity
|
41
|
+
stack = Stack.create!(
|
42
|
+
code: commodity.batch_no,
|
43
|
+
length: 100,
|
44
|
+
width: 100,
|
45
|
+
height: 100,
|
46
|
+
start_x: 2,
|
47
|
+
start_y: 2,
|
48
|
+
commodity: commodity,
|
49
|
+
store: authorization.store,
|
50
|
+
commodity_status: Commodity::GOOD,
|
51
|
+
stack_status: Stack::ALLOCATED
|
52
|
+
)
|
53
|
+
ReceiptTransaction.create!(
|
54
|
+
receipt_authorization: authorization,
|
55
|
+
destination: stack,
|
56
|
+
quantity: authorization.received_quantity,
|
57
|
+
status: Transaction::DRAFT,
|
58
|
+
transaction_date: Date.today
|
59
|
+
)
|
60
|
+
stack
|
61
|
+
end
|
62
|
+
|
30
63
|
def stack(authorization_id)
|
31
64
|
authorization = ReceiptAuthorization.find(authorization_id)
|
32
65
|
unless authorization.dispatch.dispatch_status == Dispatch::RECEIVED
|
@@ -43,6 +76,23 @@ module Cats
|
|
43
76
|
authorization.dispatch.stack
|
44
77
|
authorization
|
45
78
|
end
|
79
|
+
|
80
|
+
def receipt_authorization(id)
|
81
|
+
item = DispatchPlanItem.find(id).includes(
|
82
|
+
:destination,
|
83
|
+
:unit,
|
84
|
+
commodity: { project: :source }
|
85
|
+
)
|
86
|
+
{
|
87
|
+
date: Date.today,
|
88
|
+
reference_no: item.reference_no,
|
89
|
+
destination: item.destination.name,
|
90
|
+
source: item.commodity.project.source.description,
|
91
|
+
commodity: "#{item.commodity.project.source.commodity_name} (#{item.commodity.batch_no})",
|
92
|
+
unit: item.unit.abbreviation,
|
93
|
+
quantity: item.quantity
|
94
|
+
}
|
95
|
+
end
|
46
96
|
end
|
47
97
|
end
|
48
98
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class LocationService
|
4
|
+
# This method creates FDP from location params, but also creates the
|
5
|
+
# related dummy warehouse and store for the FDP
|
6
|
+
def create_fdp(code, name, parent_id, description = nil)
|
7
|
+
ActiveRecord::Base.transaction do
|
8
|
+
fdp = Location.create!(
|
9
|
+
code: code, name: name, description: description, location_type: Location::FDP, parent_id: parent_id
|
10
|
+
)
|
11
|
+
wh_code = "FDP-WH-#{fdp.code}"
|
12
|
+
st_code = "FDP-ST-#{fdp.code}"
|
13
|
+
|
14
|
+
warehouse = Location.create!(
|
15
|
+
code: wh_code, name: wh_code, location_type: Location::WAREHOUSE, parent: fdp
|
16
|
+
)
|
17
|
+
Store.create!(
|
18
|
+
code: st_code, name: st_code, length: 200, width: 200, height: 200, warehouse: warehouse
|
19
|
+
)
|
20
|
+
fdp
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/config/routes.rb
CHANGED
@@ -41,6 +41,7 @@ Cats::Core::Engine.routes.draw do
|
|
41
41
|
|
42
42
|
get '/regions/:id/woredas', controller: :locations, action: :woredas, as: :region_woredas
|
43
43
|
post '/locations/filter', controller: :locations, action: :filter
|
44
|
+
post '/locations/fdp/create', controller: :locations, action: :create_fdp
|
44
45
|
resources :locations, except: %i[destroy] do
|
45
46
|
member do
|
46
47
|
get 'children'
|
@@ -142,6 +143,18 @@ Cats::Core::Engine.routes.draw do
|
|
142
143
|
action: :storekeeper_authorizations,
|
143
144
|
as: :storekeeper_receipt_authorizations
|
144
145
|
)
|
146
|
+
post(
|
147
|
+
'/storekeeper/:id/assign_stores',
|
148
|
+
controller: :stores,
|
149
|
+
action: :assign_store,
|
150
|
+
as: :assign_stores_to_storekeeper
|
151
|
+
)
|
152
|
+
post(
|
153
|
+
'/storekeeper/:id/unassign_stores',
|
154
|
+
controller: :stores,
|
155
|
+
action: :unassign_store,
|
156
|
+
as: :unassign_stores_to_storekeeper
|
157
|
+
)
|
145
158
|
post(
|
146
159
|
'/receipt_authorizations/generate',
|
147
160
|
controller: :receipt_authorizations,
|
@@ -167,7 +180,9 @@ Cats::Core::Engine.routes.draw do
|
|
167
180
|
action: :create_allocation,
|
168
181
|
as: :allocation_transaction
|
169
182
|
)
|
183
|
+
post '/dispatch_transactions/filter', controller: :dispatch_transactions, action: :filter
|
170
184
|
resources :dispatch_transactions, except: %i[index new edit destroy]
|
185
|
+
post '/receipt_transactions/filter', controller: :receipt_transactions, action: :filter
|
171
186
|
resources :receipt_transactions, except: %i[index new edit destroy]
|
172
187
|
resources :lost_commodities, except: %i[index destroy]
|
173
188
|
get '/plans/:id/round_plans', controller: :round_plans, action: :index, as: :round_plans_plan
|
@@ -198,6 +213,10 @@ Cats::Core::Engine.routes.draw do
|
|
198
213
|
|
199
214
|
get '/warehouses/:id/stores', controller: :stores, action: :index, as: :stores_warehouse
|
200
215
|
get '/hubs/:id/stores', controller: :stores, action: :stores_for_hub, as: :stores_hub
|
201
|
-
resources :stores, only: %i[index show create update]
|
216
|
+
resources :stores, only: %i[index show create update] do
|
217
|
+
member do
|
218
|
+
get 'fdp'
|
219
|
+
end
|
220
|
+
end
|
202
221
|
post '/stores/filter', controller: :stores, action: :filter
|
203
222
|
end
|
@@ -2,6 +2,7 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1]
|
|
2
2
|
def change
|
3
3
|
create_table :cats_core_purchase_orders do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
5
6
|
t.date :order_date, null: false
|
6
7
|
t.string :requisition_no
|
7
8
|
t.string :supplier, null: false
|
@@ -17,10 +17,7 @@ class CreateCatsCoreStores < ActiveRecord::Migration[6.1]
|
|
17
17
|
null: false,
|
18
18
|
index: { name: 'warehouse_on_stores_indx' },
|
19
19
|
foreign_key: { to_table: :cats_core_locations }
|
20
|
-
|
21
|
-
null: false,
|
22
|
-
index: { name: 'store_keeper_on_store_indx' },
|
23
|
-
foreign_key: { to_table: :cats_core_users }
|
20
|
+
|
24
21
|
t.timestamps
|
25
22
|
end
|
26
23
|
end
|
@@ -2,6 +2,7 @@ class CreateCatsCoreSwaps < ActiveRecord::Migration[7.0]
|
|
2
2
|
def change
|
3
3
|
create_table :cats_core_swaps do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
5
6
|
t.string :swapper, null: false
|
6
7
|
t.date :agreement_date, null: false
|
7
8
|
t.float :issued_quantity, null: false
|
data/lib/cats/core/version.rb
CHANGED
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :dispatch_plan_item, class: 'Cats::Core::DispatchPlanItem' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
4
|
source factory: :location
|
5
|
-
destination factory: :
|
5
|
+
destination factory: :woreda
|
6
6
|
dispatch_plan
|
7
7
|
quantity { 100 }
|
8
8
|
unit factory: :unit_of_measure
|
@@ -19,6 +19,15 @@ FactoryBot.define do
|
|
19
19
|
factory :fdp, parent: :woreda, class: 'Cats::Core::Location' do
|
20
20
|
location_type { Cats::Core::Location::FDP }
|
21
21
|
parent factory: :woreda
|
22
|
+
|
23
|
+
trait :with_store do
|
24
|
+
after(:create) do |obj|
|
25
|
+
wh_code = "FDP-WH-#{obj.code}"
|
26
|
+
st_code = "FDP-ST-#{obj.code}"
|
27
|
+
warehouse = create(:warehouse, code: wh_code, name: wh_code, parent: obj)
|
28
|
+
create(:store, code: st_code, name: st_code, warehouse: warehouse)
|
29
|
+
end
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
33
|
factory :hub, parent: :location, class: 'Cats::Core::Location' do
|
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.48
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -377,6 +377,7 @@ files:
|
|
377
377
|
- app/services/cats/core/beneficiary_service.rb
|
378
378
|
- app/services/cats/core/dispatch_plan_service.rb
|
379
379
|
- app/services/cats/core/dispatch_service.rb
|
380
|
+
- app/services/cats/core/location_service.rb
|
380
381
|
- app/services/cats/core/menu_service.rb
|
381
382
|
- app/services/cats/core/notification_service.rb
|
382
383
|
- app/services/cats/core/round_plan_service.rb
|