cats_core 1.4.21 → 1.4.24
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_authorizations_controller.rb +35 -0
- data/app/controllers/cats/core/dispatch_plan_items_controller.rb +2 -2
- data/app/controllers/cats/core/dispatch_transactions_controller.rb +4 -4
- data/app/controllers/cats/core/dispatches_controller.rb +7 -2
- data/app/controllers/cats/core/lost_commodities_controller.rb +2 -2
- data/app/controllers/cats/core/receipt_authorizations_controller.rb +27 -0
- data/app/controllers/cats/core/receipt_transactions_controller.rb +2 -20
- data/app/controllers/cats/core/receipts_controller.rb +2 -28
- data/app/models/cats/core/authorization.rb +77 -0
- data/app/models/cats/core/dispatch.rb +30 -48
- data/app/models/cats/core/dispatch_authorization.rb +13 -0
- data/app/models/cats/core/dispatch_plan_item.rb +1 -0
- data/app/models/cats/core/dispatch_transaction.rb +39 -2
- data/app/models/cats/core/lost_commodity.rb +2 -3
- data/app/models/cats/core/receipt.rb +3 -37
- data/app/models/cats/core/receipt_authorization.rb +22 -0
- data/app/models/cats/core/receipt_transaction.rb +17 -14
- data/app/models/cats/core/transaction.rb +0 -30
- data/app/serializers/cats/core/dispatch_authorization_serializer.rb +8 -0
- data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +1 -1
- data/app/serializers/cats/core/dispatch_transaction_serializer.rb +1 -2
- data/app/serializers/cats/core/lost_commodity_serializer.rb +1 -1
- data/app/serializers/cats/core/receipt_authorization_serializer.rb +8 -0
- data/app/serializers/cats/core/receipt_serializer.rb +1 -2
- data/app/serializers/cats/core/receipt_transaction_serializer.rb +1 -5
- data/app/services/cats/core/authorization_service.rb +25 -0
- data/config/routes.rb +26 -9
- data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +1 -0
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +4 -0
- data/db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb +22 -0
- data/db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb +9 -3
- data/db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb +24 -0
- data/db/migrate/20210727105834_create_cats_core_receipts.rb +15 -0
- data/db/migrate/20210728041505_create_cats_core_lost_commodities.rb +3 -4
- data/db/migrate/20210814160628_create_cats_core_receipt_transactions.rb +3 -3
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_authorizations.rb +26 -0
- data/spec/factories/cats/core/dispatch_plan_items.rb +1 -0
- data/spec/factories/cats/core/dispatch_transactions.rb +2 -7
- data/spec/factories/cats/core/dispatches.rb +38 -3
- data/spec/factories/cats/core/lost_commodities.rb +1 -2
- data/spec/factories/cats/core/receipt_authorizations.rb +25 -0
- data/spec/factories/cats/core/receipt_transactions.rb +2 -22
- data/spec/factories/cats/core/receipts.rb +2 -9
- data/spec/factories/cats/core/stacks.rb +1 -1
- metadata +15 -4
- data/app/services/cats/core/receipt_service.rb +0 -48
- data/db/migrate/20210727074646_create_cats_core_receipts.rb +0 -20
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.24
|
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-05-
|
11
|
+
date: 2022-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- app/controllers/cats/core/commodities_controller.rb
|
236
236
|
- app/controllers/cats/core/commodity_categories_controller.rb
|
237
237
|
- app/controllers/cats/core/currencies_controller.rb
|
238
|
+
- app/controllers/cats/core/dispatch_authorizations_controller.rb
|
238
239
|
- app/controllers/cats/core/dispatch_plan_items_controller.rb
|
239
240
|
- app/controllers/cats/core/dispatch_plans_controller.rb
|
240
241
|
- app/controllers/cats/core/dispatch_transactions_controller.rb
|
@@ -243,6 +244,7 @@ files:
|
|
243
244
|
- app/controllers/cats/core/lost_commodities_controller.rb
|
244
245
|
- app/controllers/cats/core/menus_controller.rb
|
245
246
|
- app/controllers/cats/core/notifications_controller.rb
|
247
|
+
- app/controllers/cats/core/receipt_authorizations_controller.rb
|
246
248
|
- app/controllers/cats/core/receipt_transactions_controller.rb
|
247
249
|
- app/controllers/cats/core/receipts_controller.rb
|
248
250
|
- app/controllers/cats/core/roles_controller.rb
|
@@ -258,6 +260,7 @@ files:
|
|
258
260
|
- app/jobs/cats/core/application_job.rb
|
259
261
|
- app/models/cats/core/application_module.rb
|
260
262
|
- app/models/cats/core/application_record.rb
|
263
|
+
- app/models/cats/core/authorization.rb
|
261
264
|
- app/models/cats/core/beneficiary.rb
|
262
265
|
- app/models/cats/core/beneficiary_category.rb
|
263
266
|
- app/models/cats/core/beneficiary_plan_item.rb
|
@@ -268,6 +271,7 @@ files:
|
|
268
271
|
- app/models/cats/core/contract_item.rb
|
269
272
|
- app/models/cats/core/currency.rb
|
270
273
|
- app/models/cats/core/dispatch.rb
|
274
|
+
- app/models/cats/core/dispatch_authorization.rb
|
271
275
|
- app/models/cats/core/dispatch_plan.rb
|
272
276
|
- app/models/cats/core/dispatch_plan_item.rb
|
273
277
|
- app/models/cats/core/dispatch_transaction.rb
|
@@ -290,6 +294,7 @@ files:
|
|
290
294
|
- app/models/cats/core/purchase_order.rb
|
291
295
|
- app/models/cats/core/ration.rb
|
292
296
|
- app/models/cats/core/receipt.rb
|
297
|
+
- app/models/cats/core/receipt_authorization.rb
|
293
298
|
- app/models/cats/core/receipt_transaction.rb
|
294
299
|
- app/models/cats/core/rhn_request.rb
|
295
300
|
- app/models/cats/core/role.rb
|
@@ -328,12 +333,14 @@ files:
|
|
328
333
|
- app/serializers/cats/core/commodity_category_serializer.rb
|
329
334
|
- app/serializers/cats/core/commodity_serializer.rb
|
330
335
|
- app/serializers/cats/core/currency_serializer.rb
|
336
|
+
- app/serializers/cats/core/dispatch_authorization_serializer.rb
|
331
337
|
- app/serializers/cats/core/dispatch_plan_item_serializer.rb
|
332
338
|
- app/serializers/cats/core/dispatch_plan_serializer.rb
|
333
339
|
- app/serializers/cats/core/dispatch_serializer.rb
|
334
340
|
- app/serializers/cats/core/dispatch_transaction_serializer.rb
|
335
341
|
- app/serializers/cats/core/location_serializer.rb
|
336
342
|
- app/serializers/cats/core/lost_commodity_serializer.rb
|
343
|
+
- app/serializers/cats/core/receipt_authorization_serializer.rb
|
337
344
|
- app/serializers/cats/core/receipt_serializer.rb
|
338
345
|
- app/serializers/cats/core/receipt_transaction_serializer.rb
|
339
346
|
- app/serializers/cats/core/role_menu_serializer.rb
|
@@ -345,11 +352,11 @@ files:
|
|
345
352
|
- app/serializers/cats/core/unit_conversion_serializer.rb
|
346
353
|
- app/serializers/cats/core/unit_of_measure_serializer.rb
|
347
354
|
- app/serializers/cats/core/user_serializer.rb
|
355
|
+
- app/services/cats/core/authorization_service.rb
|
348
356
|
- app/services/cats/core/dispatch_plan_service.rb
|
349
357
|
- app/services/cats/core/dispatch_service.rb
|
350
358
|
- app/services/cats/core/menu_service.rb
|
351
359
|
- app/services/cats/core/notification_service.rb
|
352
|
-
- app/services/cats/core/receipt_service.rb
|
353
360
|
- app/services/cats/core/round_plan_service.rb
|
354
361
|
- app/services/cats/core/space_service.rb
|
355
362
|
- app/services/cats/core/stack_service.rb
|
@@ -387,10 +394,12 @@ files:
|
|
387
394
|
- db/migrate/20210718043328_create_cats_core_dispatch_plans.rb
|
388
395
|
- db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb
|
389
396
|
- db/migrate/20210718045516_create_cats_core_dispatches.rb
|
397
|
+
- db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb
|
390
398
|
- db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb
|
391
399
|
- db/migrate/20210719133710_create_cats_core_stacking_rules.rb
|
392
400
|
- db/migrate/20210724074657_create_cats_core_notifications.rb
|
393
|
-
- db/migrate/
|
401
|
+
- db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb
|
402
|
+
- db/migrate/20210727105834_create_cats_core_receipts.rb
|
394
403
|
- db/migrate/20210728041505_create_cats_core_lost_commodities.rb
|
395
404
|
- db/migrate/20210814160628_create_cats_core_receipt_transactions.rb
|
396
405
|
- db/migrate/20210814175406_create_cats_core_stack_transactions.rb
|
@@ -435,6 +444,7 @@ files:
|
|
435
444
|
- spec/factories/cats/core/commodity_substitutions.rb
|
436
445
|
- spec/factories/cats/core/contract_items.rb
|
437
446
|
- spec/factories/cats/core/currencies.rb
|
447
|
+
- spec/factories/cats/core/dispatch_authorizations.rb
|
438
448
|
- spec/factories/cats/core/dispatch_plan_items.rb
|
439
449
|
- spec/factories/cats/core/dispatch_plans.rb
|
440
450
|
- spec/factories/cats/core/dispatch_transactions.rb
|
@@ -457,6 +467,7 @@ files:
|
|
457
467
|
- spec/factories/cats/core/programs.rb
|
458
468
|
- spec/factories/cats/core/purchase_orders.rb
|
459
469
|
- spec/factories/cats/core/rations.rb
|
470
|
+
- spec/factories/cats/core/receipt_authorizations.rb
|
460
471
|
- spec/factories/cats/core/receipt_transactions.rb
|
461
472
|
- spec/factories/cats/core/receipts.rb
|
462
473
|
- spec/factories/cats/core/rhn_requests.rb
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class ReceiptService
|
4
|
-
def start_stacking(receipt)
|
5
|
-
raise(StandardError, 'Receipt should be confirmed.') unless receipt.status == Cats::Core::Receipt::CONFIRMED
|
6
|
-
|
7
|
-
raise(StandardError, 'There are no stack assignments in receipt.') if receipt.receipt_transactions.count.zero?
|
8
|
-
|
9
|
-
receipt.status = Cats::Core::Receipt::STACKING
|
10
|
-
receipt.save!
|
11
|
-
receipt
|
12
|
-
end
|
13
|
-
|
14
|
-
def finish_stacking(receipt)
|
15
|
-
unless receipt.status == Cats::Core::Receipt::STACKING
|
16
|
-
raise(StandardError, 'Receipt should be in stacking state.')
|
17
|
-
end
|
18
|
-
|
19
|
-
receipt.receipt_transactions.each(&:commit)
|
20
|
-
receipt.status = Cats::Core::Receipt::STACKED
|
21
|
-
receipt.save!
|
22
|
-
receipt
|
23
|
-
end
|
24
|
-
|
25
|
-
def init(params)
|
26
|
-
receipt = Cats::Core::Receipt.find_by(
|
27
|
-
dispatch_id: params[:dispatch_id],
|
28
|
-
commodity_status: params[:commodity_status]
|
29
|
-
)
|
30
|
-
|
31
|
-
if receipt
|
32
|
-
# We can assume that the plan item is destination authorized.
|
33
|
-
# Therefore no need for checking destination authorization.
|
34
|
-
receipt.quantity += params[:quantity]
|
35
|
-
return receipt
|
36
|
-
end
|
37
|
-
|
38
|
-
# Check if plan item is destination authorized
|
39
|
-
dispatch = Dispatch.find(params[:dispatch_id])
|
40
|
-
status = dispatch.dispatch_plan_item.status
|
41
|
-
statuses = [DispatchPlanItem::DESTINATION_AUTHORIZED, DispatchPlanItem::AUTHORIZED]
|
42
|
-
raise(StandardError, 'Plan item is not destination authorized.') unless statuses.include?(status)
|
43
|
-
|
44
|
-
Receipt.new(params)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class CreateCatsCoreReceipts < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_receipts do |t|
|
4
|
-
t.references :dispatch,
|
5
|
-
null: false,
|
6
|
-
index: { name: 'dispatch_on_receipts_indx' },
|
7
|
-
foreign_key: { to_table: :cats_core_dispatches }
|
8
|
-
t.float :quantity, null: false
|
9
|
-
t.string :commodity_status, null: false, default: 'Good'
|
10
|
-
t.string :status, null: false, default: 'Draft'
|
11
|
-
t.string :remark
|
12
|
-
t.references :prepared_by,
|
13
|
-
null: false,
|
14
|
-
index: { name: 'pb_on_receipts_indx' },
|
15
|
-
foreign_key: { to_table: :cats_core_users }
|
16
|
-
|
17
|
-
t.timestamps
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|