cats_core 1.5.19 → 1.5.21
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 +3 -3
- data/app/controllers/cats/core/dispatch_authorizations_controller.rb +4 -4
- data/app/controllers/cats/core/dispatch_plan_items_controller.rb +1 -1
- data/app/controllers/cats/core/dispatch_plans_controller.rb +2 -2
- data/app/controllers/cats/core/dispatch_transactions_controller.rb +1 -1
- data/app/controllers/cats/core/dispatches_controller.rb +5 -5
- data/app/controllers/cats/core/loans_controller.rb +1 -1
- data/app/controllers/cats/core/purchase_orders_controller.rb +2 -2
- data/app/controllers/cats/core/receipt_authorizations_controller.rb +5 -5
- data/app/controllers/cats/core/receipt_transactions_controller.rb +2 -2
- data/app/controllers/cats/core/receipts_controller.rb +1 -1
- data/app/controllers/cats/core/roles_controller.rb +1 -1
- data/app/controllers/cats/core/round_beneficiaries_controller.rb +5 -5
- data/app/controllers/cats/core/round_plans_controller.rb +3 -3
- data/app/controllers/cats/core/stack_transactions_controller.rb +1 -1
- data/app/controllers/cats/core/stacks_controller.rb +2 -2
- data/app/controllers/cats/core/stores_controller.rb +1 -1
- data/app/controllers/cats/core/swaps_controller.rb +2 -2
- data/app/controllers/cats/core/users_controller.rb +1 -1
- data/app/controllers/concerns/cats/core/common.rb +15 -16
- data/app/models/cats/core/authorization.rb +1 -1
- data/app/models/cats/core/beneficiary_plan_item.rb +1 -1
- data/app/models/cats/core/commodity.rb +12 -12
- data/app/models/cats/core/commodity_substitution.rb +2 -2
- data/app/models/cats/core/dispatch.rb +16 -16
- data/app/models/cats/core/dispatch_authorization.rb +3 -3
- data/app/models/cats/core/dispatch_plan.rb +6 -6
- data/app/models/cats/core/dispatch_plan_item.rb +10 -10
- data/app/models/cats/core/dispatch_transaction.rb +8 -8
- data/app/models/cats/core/location.rb +2 -2
- data/app/models/cats/core/receipt_authorization.rb +2 -2
- data/app/models/cats/core/receipt_transaction.rb +2 -2
- data/app/models/cats/core/round_beneficiary.rb +4 -4
- data/app/models/cats/core/round_plan.rb +2 -2
- data/app/models/cats/core/round_plan_item.rb +2 -2
- data/app/models/cats/core/route.rb +2 -2
- data/app/models/cats/core/stack.rb +30 -30
- data/app/models/cats/core/stacking_rule.rb +2 -2
- data/app/models/cats/core/store.rb +21 -21
- data/app/models/cats/core/transporter.rb +2 -2
- data/app/models/cats/core/unit_conversion.rb +1 -3
- data/app/serializers/cats/core/cash_donation_serializer.rb +1 -1
- data/app/serializers/cats/core/commodity_donation_serializer.rb +2 -2
- data/app/serializers/cats/core/commodity_serializer.rb +2 -2
- data/app/serializers/cats/core/dispatch_authorization_serializer.rb +2 -2
- data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +3 -3
- data/app/serializers/cats/core/dispatch_plan_serializer.rb +1 -1
- data/app/serializers/cats/core/dispatch_serializer.rb +2 -2
- data/app/serializers/cats/core/dispatch_transaction_serializer.rb +1 -1
- data/app/serializers/cats/core/loan_serializer.rb +1 -1
- data/app/serializers/cats/core/purchase_order_serializer.rb +2 -2
- data/app/serializers/cats/core/receipt_authorization_serializer.rb +2 -2
- data/app/serializers/cats/core/receipt_serializer.rb +1 -1
- data/app/serializers/cats/core/receipt_transaction_serializer.rb +2 -2
- data/app/serializers/cats/core/round_beneficiary_serializer.rb +1 -1
- data/app/serializers/cats/core/round_plan_serializer.rb +1 -1
- data/app/serializers/cats/core/stack_serializer.rb +1 -1
- data/app/serializers/cats/core/store_serializer.rb +1 -1
- data/app/serializers/cats/core/swap_serializer.rb +2 -2
- data/app/services/cats/core/authorization_service.rb +3 -9
- data/app/services/cats/core/beneficiary_service.rb +2 -2
- data/app/services/cats/core/dispatch_plan_service.rb +1 -1
- data/app/services/cats/core/dispatch_service.rb +18 -20
- data/app/services/cats/core/notification_service.rb +1 -1
- data/app/services/cats/core/round_plan_service.rb +4 -6
- data/app/services/cats/core/space_service.rb +6 -6
- data/app/services/cats/core/stack_service.rb +8 -8
- data/app/services/cats/core/user_service.rb +1 -1
- data/db/migrate/20210715114910_create_cats_core_users.rb +3 -3
- data/db/migrate/20210715120018_create_cats_core_roles.rb +11 -11
- data/db/migrate/20210715121244_create_cats_core_menus.rb +3 -3
- data/db/migrate/20210715122141_create_cats_core_menu_items.rb +3 -3
- data/db/migrate/20210715122423_create_cats_core_role_menus.rb +12 -12
- data/db/migrate/20210717031810_create_cats_core_plans.rb +3 -3
- data/db/migrate/20210717032024_create_cats_core_plan_items.rb +19 -19
- data/db/migrate/20210717032260_create_cats_core_beneficiary_categories.rb +3 -3
- data/db/migrate/20210717032270_create_cats_core_rations.rb +9 -9
- data/db/migrate/20210717032290_create_cats_core_beneficiary_plan_items.rb +7 -7
- data/db/migrate/20210717032295_create_cats_core_plan_item_details.rb +7 -7
- data/db/migrate/20210717032330_create_cats_core_commodity_donations.rb +12 -12
- data/db/migrate/20210717032408_create_cats_core_cash_donations.rb +6 -6
- data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +12 -12
- data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +12 -12
- data/db/migrate/20210717032927_create_cats_core_projects.rb +3 -3
- data/db/migrate/20210717033223_create_cats_core_commodities.rb +9 -9
- data/db/migrate/20210717140855_create_cats_core_stores.rb +3 -3
- data/db/migrate/20210717171101_create_cats_core_stacks.rb +9 -9
- data/db/migrate/20210718040129_create_cats_core_routes.rb +9 -9
- data/db/migrate/20210718042755_create_cats_core_rhn_requests.rb +6 -6
- data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +6 -6
- data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +15 -15
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +12 -12
- data/db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb +12 -12
- data/db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb +10 -10
- data/db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb +12 -12
- data/db/migrate/20210727105834_create_cats_core_receipts.rb +6 -6
- data/db/migrate/20210728041505_create_cats_core_lost_commodities.rb +6 -6
- data/db/migrate/20210814160628_create_cats_core_receipt_transactions.rb +9 -9
- data/db/migrate/20210814175406_create_cats_core_stack_transactions.rb +9 -9
- data/db/migrate/20211215114737_create_cats_core_transport_plans.rb +3 -3
- data/db/migrate/20211215114835_create_cats_core_transport_plan_items.rb +9 -9
- data/db/migrate/20211215121151_create_cats_core_transport_bids.rb +3 -3
- data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +9 -9
- data/db/migrate/20211229160125_create_cats_core_transport_offers.rb +7 -7
- data/db/migrate/20211229160126_create_cats_core_offer_items.rb +6 -6
- data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +6 -6
- data/db/migrate/20211229160128_create_cats_core_contract_items.rb +9 -9
- data/db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb +10 -10
- data/db/migrate/20220103152802_create_cats_core_tenderers.rb +6 -6
- data/db/migrate/20220107121752_create_cats_core_round_plans.rb +6 -6
- data/db/migrate/20220107122280_create_cats_core_round_rations.rb +12 -12
- data/db/migrate/20220107125025_create_cats_core_round_plan_items.rb +18 -18
- data/db/migrate/20220107126025_create_cats_core_beneficiary_round_plan_items.rb +7 -7
- data/db/migrate/20220107132433_create_cats_core_round_plan_item_details.rb +9 -9
- data/db/migrate/20220209083928_create_cats_core_hub_authorizations.rb +12 -12
- data/db/migrate/20220416143416_create_cats_core_unit_conversions.rb +7 -7
- data/db/migrate/20220417105839_create_cats_core_transport_requisitions.rb +12 -12
- data/db/migrate/20220417123835_create_cats_core_transport_requisition_items.rb +9 -9
- data/db/migrate/20220417151821_create_cats_core_transport_requisition_details.rb +6 -6
- data/db/migrate/20220506082329_create_cats_core_transport_orders.rb +9 -9
- data/db/migrate/20220506083042_create_cats_core_transport_order_items.rb +12 -12
- data/db/migrate/20220511082354_create_cats_core_beneficiaries.rb +6 -6
- data/db/migrate/20220626063501_create_cats_core_loans.rb +6 -6
- data/db/migrate/20220626063757_create_cats_core_swaps.rb +12 -12
- data/db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb +12 -12
- data/db/migrate/20220923190857_create_cats_core_application_settings.rb +3 -3
- data/lib/cats/core/engine.rb +1 -3
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_authorizations.rb +1 -1
- data/spec/factories/cats/core/dispatch_plan_items.rb +1 -1
- data/spec/factories/cats/core/dispatches.rb +4 -4
- data/spec/factories/cats/core/round_plan_item_details.rb +1 -1
- metadata +41 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 209258e5710d38a1deaa5865706bd6d1c271aaf11b9a26463d0ff6e5e7012c64
|
4
|
+
data.tar.gz: e0eb78845adfaf73e866c5792aeae9e5e6dd2ff94e0733053a39c1f375fecf4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8ab8760cd5c8bbd9c7ac30fc50b5766b81db8218e689f330ddfdc4b72d8eb173af4c1f219d250065d2f0cd17ff1115738b042de12f81d015089311ffe4c82a
|
7
|
+
data.tar.gz: 59164f38e38cf097433f9441bab3c38c8bee69b2e8808acd9d0233c942b01e25b38005e264feaac968bfb415cb7109d53a03b5b270cbad6fc4f994be9bf3ec24
|
@@ -13,7 +13,7 @@ module Cats
|
|
13
13
|
commodity = Commodity.find(params[:id])
|
14
14
|
result = commodity.approve
|
15
15
|
render json: {success: result, data: serialize(commodity)}
|
16
|
-
rescue => e
|
16
|
+
rescue StandardError => e
|
17
17
|
render json: {success: false, error: e.message}
|
18
18
|
end
|
19
19
|
|
@@ -26,8 +26,8 @@ module Cats
|
|
26
26
|
|
27
27
|
def model_params
|
28
28
|
params.require(:payload).permit(:batch_no, :description, :unit_of_measure_id, :project_id, :commodity_grade,
|
29
|
-
|
30
|
-
|
29
|
+
:source_type, :quantity, :best_use_before, :volume_per_metric_ton,
|
30
|
+
:arrival_status, :shipping_reference, :package_unit_id)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -25,7 +25,7 @@ module Cats
|
|
25
25
|
authorization = DispatchAuthorization.find(params[:id])
|
26
26
|
authorization = authorization.confirm
|
27
27
|
render json: {success: true, data: serialize(authorization)}
|
28
|
-
rescue => e
|
28
|
+
rescue StandardError => e
|
29
29
|
render json: {success: false, error: e.message}
|
30
30
|
end
|
31
31
|
|
@@ -33,9 +33,9 @@ module Cats
|
|
33
33
|
storekeeper = User.find(params[:id])
|
34
34
|
stores = storekeeper.stores
|
35
35
|
authorizations = DispatchAuthorization.joins(:dispatch)
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
.includes(:dispatch, :store, :authorized_by, :unit)
|
37
|
+
.where(store: stores, dispatch: {dispatch_status: Dispatch::APPROVED})
|
38
|
+
.reverse_order
|
39
39
|
render json: {success: true, data: serialize(authorizations)}
|
40
40
|
end
|
41
41
|
|
@@ -30,7 +30,7 @@ module Cats
|
|
30
30
|
|
31
31
|
def model_params
|
32
32
|
params.require(:payload).permit(:reference_no, :dispatch_plan_id, :source_id, :destination_id, :quantity,
|
33
|
-
|
33
|
+
:unit_id, :commodity_status, :status, :commodity_id)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -23,7 +23,7 @@ module Cats
|
|
23
23
|
service = DispatchPlanService.new
|
24
24
|
plan = service.create(model_params, current_user)
|
25
25
|
render json: {success: true, data: serialize(plan)}, status: :created
|
26
|
-
rescue => e
|
26
|
+
rescue StandardError => e
|
27
27
|
render json: {success: false, error: e.message}, status: :unprocessable_entity
|
28
28
|
end
|
29
29
|
|
@@ -44,7 +44,7 @@ module Cats
|
|
44
44
|
plan = DispatchPlan.find(params[:id])
|
45
45
|
plan = service.approve(plan)
|
46
46
|
render json: {success: true, data: serialize(plan)}
|
47
|
-
rescue => e
|
47
|
+
rescue StandardError => e
|
48
48
|
render json: {success: false, error: e.message}
|
49
49
|
end
|
50
50
|
|
@@ -30,21 +30,21 @@ module Cats
|
|
30
30
|
dispatch = set_object
|
31
31
|
dispatch.approve
|
32
32
|
render json: {success: true, data: serialize(dispatch)}
|
33
|
-
rescue => e
|
33
|
+
rescue StandardError => e
|
34
34
|
render json: {success: false, error: e.message}
|
35
35
|
end
|
36
36
|
|
37
37
|
def start
|
38
38
|
dispatch = @service.start(set_object)
|
39
39
|
render json: {success: true, data: serialize(dispatch)}
|
40
|
-
rescue => e
|
40
|
+
rescue StandardError => e
|
41
41
|
render json: {success: false, error: e.message}
|
42
42
|
end
|
43
43
|
|
44
44
|
def start_with_pin
|
45
45
|
dispatch = @service.start_with_pin(params[:id], start_with_pin_params[:pin])
|
46
46
|
render json: {success: true, data: serialize(dispatch)}
|
47
|
-
rescue => e
|
47
|
+
rescue StandardError => e
|
48
48
|
render json: {success: false, error: e.message}
|
49
49
|
end
|
50
50
|
|
@@ -52,7 +52,7 @@ module Cats
|
|
52
52
|
dispatch = set_object
|
53
53
|
dispatch.confirm
|
54
54
|
render json: {success: true, data: serialize(dispatch)}
|
55
|
-
rescue => e
|
55
|
+
rescue StandardError => e
|
56
56
|
render json: {success: false, error: e.message}
|
57
57
|
end
|
58
58
|
|
@@ -84,7 +84,7 @@ module Cats
|
|
84
84
|
|
85
85
|
def model_params
|
86
86
|
params.require(:payload).permit(:reference_no, :dispatch_plan_item_id, :transporter_id, :plate_no, :unit_id,
|
87
|
-
|
87
|
+
:driver_name, :driver_phone, :remark)
|
88
88
|
end
|
89
89
|
|
90
90
|
def start_with_pin_params
|
@@ -16,8 +16,8 @@ module Cats
|
|
16
16
|
|
17
17
|
def model_params
|
18
18
|
params.require(:payload).permit(:reference_no, :order_date, :requisition_no, :supplier, :cash_donation_id,
|
19
|
-
|
20
|
-
|
19
|
+
:commodity_category_id, :quantity, :purchase_type, :unit_id, :price,
|
20
|
+
:currency_id, :description)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -25,7 +25,7 @@ module Cats
|
|
25
25
|
authorization = ReceiptAuthorization.find(params[:id])
|
26
26
|
authorization.confirm
|
27
27
|
render json: {success: true, data: serialize(authorization)}
|
28
|
-
rescue => e
|
28
|
+
rescue StandardError => e
|
29
29
|
render json: {success: false, error: e.message}
|
30
30
|
end
|
31
31
|
|
@@ -35,7 +35,7 @@ module Cats
|
|
35
35
|
params[:id], driver_confirm_params[:pin], driver_confirm_params[:receipt_number]
|
36
36
|
)
|
37
37
|
render json: {success: true, data: serialize(authorization)}
|
38
|
-
rescue => e
|
38
|
+
rescue StandardError => e
|
39
39
|
render json: {success: false, error: e.message}
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ module Cats
|
|
44
44
|
authorization = ReceiptAuthorization.find(params[:id])
|
45
45
|
authorization = service.stack(authorization.id)
|
46
46
|
render json: {success: true, data: serialize(authorization)}
|
47
|
-
rescue => e
|
47
|
+
rescue StandardError => e
|
48
48
|
render json: {success: false, error: e.message}
|
49
49
|
end
|
50
50
|
|
@@ -53,7 +53,7 @@ module Cats
|
|
53
53
|
status = params[:status]
|
54
54
|
stores = storekeeper.stores
|
55
55
|
authorizations = ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit)
|
56
|
-
|
56
|
+
.where(store: stores, status: status)
|
57
57
|
render json: {success: true, data: serialize(authorizations)}
|
58
58
|
end
|
59
59
|
|
@@ -71,7 +71,7 @@ module Cats
|
|
71
71
|
|
72
72
|
def model_params
|
73
73
|
params.require(:payload).permit(:dispatch_id, :store_id, :quantity, :unit_id, :remark, :status,
|
74
|
-
|
74
|
+
:authorized_by_id)
|
75
75
|
end
|
76
76
|
|
77
77
|
def driver_confirm_params
|
@@ -6,7 +6,7 @@ module Cats
|
|
6
6
|
def index
|
7
7
|
super do
|
8
8
|
ReceiptTransaction.includes(:destination, {receipt_authorization: :dispatch}, :unit)
|
9
|
-
|
9
|
+
.where(receipt_authorization_id: params[:id])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -19,7 +19,7 @@ module Cats
|
|
19
19
|
|
20
20
|
def model_params
|
21
21
|
params.require(:payload).permit(:receipt_authorization_id, :receipt_number, :destination_id,
|
22
|
-
|
22
|
+
:transaction_date, :quantity, :unit_id)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,8 +5,8 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
beneficiaries = RoundBeneficiary.joins(:round_plan_item)
|
8
|
-
|
9
|
-
|
8
|
+
.where(round_plan_item: {round_plan_id: params[:id]})
|
9
|
+
.includes(:beneficiary, :commodity_category, :unit)
|
10
10
|
render json: {success: true, data: serialize(beneficiaries)}
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ module Cats
|
|
14
14
|
service = BeneficiaryService.new
|
15
15
|
result = service.generate_distribution_list(params[:id])
|
16
16
|
render json: {success: result}
|
17
|
-
rescue => e
|
17
|
+
rescue StandardError => e
|
18
18
|
render json: {success: false, error: e.message}
|
19
19
|
end
|
20
20
|
|
@@ -27,7 +27,7 @@ module Cats
|
|
27
27
|
service = BeneficiaryService.new
|
28
28
|
result = service.remove_items(params[:id], common_params[:ids])
|
29
29
|
render json: {success: result}
|
30
|
-
rescue => e
|
30
|
+
rescue StandardError => e
|
31
31
|
render json: {success: false, error: e.message}
|
32
32
|
end
|
33
33
|
|
@@ -35,7 +35,7 @@ module Cats
|
|
35
35
|
service = BeneficiaryService.new
|
36
36
|
result = service.confirm_receipt(params[:id], common_params[:ids])
|
37
37
|
render json: {success: result}
|
38
|
-
rescue => e
|
38
|
+
rescue StandardError => e
|
39
39
|
render json: {success: false, error: e.message}
|
40
40
|
end
|
41
41
|
|
@@ -20,7 +20,7 @@ module Cats
|
|
20
20
|
def approve
|
21
21
|
plan = @service.approve(params[:id])
|
22
22
|
render json: {success: true, data: serialize(plan)}
|
23
|
-
rescue => e
|
23
|
+
rescue StandardError => e
|
24
24
|
render json: {success: false, error: e.message}, status: :unprocessable_entity
|
25
25
|
end
|
26
26
|
|
@@ -33,14 +33,14 @@ module Cats
|
|
33
33
|
def generate_round_needs
|
34
34
|
plan = @service.generate_round_needs(params[:id])
|
35
35
|
render json: {success: true, data: serialize(plan)}
|
36
|
-
rescue => e
|
36
|
+
rescue StandardError => e
|
37
37
|
render json: {success: false, error: e.message}
|
38
38
|
end
|
39
39
|
|
40
40
|
def remove_items
|
41
41
|
plan = @service.remove_items(params[:id], remove_params[:ids])
|
42
42
|
render json: {success: true, data: serialize(plan)}
|
43
|
-
rescue => e
|
43
|
+
rescue StandardError => e
|
44
44
|
render json: {success: false, error: e.message}
|
45
45
|
end
|
46
46
|
|
@@ -44,7 +44,7 @@ module Cats
|
|
44
44
|
stack = set_object
|
45
45
|
stack.destroy_stack
|
46
46
|
render json: {success: true, data: serialize(stack)}
|
47
|
-
rescue => e
|
47
|
+
rescue StandardError => e
|
48
48
|
render json: {success: false, error: e}
|
49
49
|
end
|
50
50
|
|
@@ -52,7 +52,7 @@ module Cats
|
|
52
52
|
|
53
53
|
def model_params
|
54
54
|
params.require(:payload).permit(:code, :length, :width, :height, :start_x, :start_y, :commodity_id, :store_id,
|
55
|
-
|
55
|
+
:commodity_status, :stack_status, :quantity, :unit_id)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -54,7 +54,7 @@ module Cats
|
|
54
54
|
|
55
55
|
def model_params
|
56
56
|
params.require("payload").permit(:id, :code, :name, :length, :width, :height, :temporary, :has_gangway,
|
57
|
-
|
57
|
+
:gangway_length, :gangway_width, :gangway_corner_dist, :warehouse_id)
|
58
58
|
end
|
59
59
|
|
60
60
|
def store_params
|
@@ -13,8 +13,8 @@ module Cats
|
|
13
13
|
|
14
14
|
def model_params
|
15
15
|
params.require(:payload).permit(:reference_no, :swapper, :agreement_date, :issued_commodity_id, :description,
|
16
|
-
|
17
|
-
|
16
|
+
:issued_quantity, :received_commodity_id, :received_quantity, :issued_unit_id,
|
17
|
+
:received_unit_id)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -10,10 +10,10 @@ module Cats
|
|
10
10
|
|
11
11
|
def index
|
12
12
|
data = if block_given?
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
yield
|
14
|
+
else
|
15
|
+
@clazz.all
|
16
|
+
end
|
17
17
|
render json: {success: true, data: serialize(data)}
|
18
18
|
end
|
19
19
|
|
@@ -23,31 +23,31 @@ module Cats
|
|
23
23
|
|
24
24
|
def create
|
25
25
|
obj = if block_given?
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
yield
|
27
|
+
else
|
28
|
+
@clazz.new(model_params)
|
29
|
+
end
|
30
30
|
if obj.save
|
31
31
|
render json: {success: true, data: serialize(obj)}, status: :created
|
32
32
|
else
|
33
33
|
render json: {success: false, error: obj.errors.full_messages[0]}, status: :unprocessable_entity
|
34
34
|
end
|
35
|
-
rescue => e
|
35
|
+
rescue StandardError => e
|
36
36
|
render json: {success: false, error: e.message}
|
37
37
|
end
|
38
38
|
|
39
39
|
def update
|
40
40
|
obj = if block_given?
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
yield
|
42
|
+
else
|
43
|
+
obj = @obj
|
44
|
+
end
|
45
45
|
if obj.update(model_params)
|
46
46
|
render json: {success: true, data: serialize(obj)}
|
47
47
|
else
|
48
48
|
render json: {success: false, error: obj.errors.full_messages[0]}, status: :unprocessable_entity
|
49
49
|
end
|
50
|
-
rescue => e
|
50
|
+
rescue StandardError => e
|
51
51
|
render json: {success: false, error: e.message}
|
52
52
|
end
|
53
53
|
|
@@ -66,8 +66,7 @@ module Cats
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# This class should be overridden by respective child controllers
|
69
|
-
def model_params
|
70
|
-
end
|
69
|
+
def model_params; end
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
@@ -52,7 +52,7 @@ module Cats
|
|
52
52
|
def transactions
|
53
53
|
return dispatch_transactions if instance_of?(DispatchAuthorization)
|
54
54
|
|
55
|
-
|
55
|
+
receipt_transactions if instance_of?(ReceiptAuthorization)
|
56
56
|
end
|
57
57
|
|
58
58
|
def confirm
|
@@ -10,7 +10,7 @@ module Cats
|
|
10
10
|
|
11
11
|
validates :rounds, presence: true, numericality: {greater_than: 0}, if: :psnp?
|
12
12
|
validates :rounds_served, presence: true, numericality: {greater_than_or_equal_to: 0}, allow_nil: true,
|
13
|
-
|
13
|
+
if: :psnp?
|
14
14
|
validates :rounds, :rounds_served, absence: true, unless: :psnp?
|
15
15
|
validate :validate_rounds
|
16
16
|
|
@@ -24,7 +24,7 @@ module Cats
|
|
24
24
|
FAECES_FROM_RODENTS = "Faeces From Rodents".freeze
|
25
25
|
UNDERWEIGHT_PACKAGE = "Underweight Package".freeze
|
26
26
|
COMMODITY_STATUSES = [GOOD, DAMAGED, LEAKAGE, WET, MOLDY, INFESTED, INSECT_INFECTED, FAECES_FROM_RODENTS,
|
27
|
-
|
27
|
+
UNDERWEIGHT_PACKAGE].freeze
|
28
28
|
|
29
29
|
# Arrival Statuses
|
30
30
|
AT_SOURCE = "At Source".freeze
|
@@ -109,17 +109,17 @@ module Cats
|
|
109
109
|
UnitConversion.harmonized_total(requests, unit_of_measure)
|
110
110
|
end
|
111
111
|
|
112
|
-
def self.ransackable_attributes(
|
113
|
-
[
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
112
|
+
def self.ransackable_attributes(_auth_object = nil)
|
113
|
+
%w[
|
114
|
+
arrival_status
|
115
|
+
batch_no
|
116
|
+
best_use_before
|
117
|
+
commodity_grade
|
118
|
+
package_unit_id
|
119
|
+
project_id
|
120
|
+
quantity
|
121
|
+
shipping_reference
|
122
|
+
status
|
123
123
|
]
|
124
124
|
end
|
125
125
|
end
|
@@ -15,12 +15,12 @@ module Cats
|
|
15
15
|
left, right = ratio.split(":")
|
16
16
|
left_correct = begin
|
17
17
|
Integer(left).is_a?(Integer)
|
18
|
-
rescue
|
18
|
+
rescue StandardError
|
19
19
|
false
|
20
20
|
end
|
21
21
|
right_correct = begin
|
22
22
|
Integer(right).is_a?(Integer)
|
23
|
-
rescue
|
23
|
+
rescue StandardError
|
24
24
|
false
|
25
25
|
end
|
26
26
|
|
@@ -102,10 +102,10 @@ module Cats
|
|
102
102
|
def self.search_commodity(batch_no)
|
103
103
|
commodity = Commodity.find_by(batch_no: batch_no)
|
104
104
|
dispatches = Dispatch.includes(:dispatch_transactions)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
.joins(:transporter)
|
106
|
+
.where(
|
107
|
+
dispatch_status: [APPROVED, STARTED]
|
108
|
+
)
|
109
109
|
dispatches.map do |dispatch|
|
110
110
|
{
|
111
111
|
batch_no: batch_no,
|
@@ -119,18 +119,18 @@ module Cats
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
def self.ransackable_attributes(
|
123
|
-
[
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
122
|
+
def self.ransackable_attributes(_auth_object = nil)
|
123
|
+
%w[
|
124
|
+
commodity_status
|
125
|
+
dispatch_plan_item_id
|
126
|
+
dispatch_status
|
127
|
+
driver_name
|
128
|
+
driver_phone
|
129
|
+
plate_no
|
130
|
+
prepared_by_id
|
131
|
+
quantity
|
132
|
+
transporter_id
|
133
|
+
unit_id
|
134
134
|
]
|
135
135
|
end
|
136
136
|
end
|
@@ -31,7 +31,7 @@ module Cats
|
|
31
31
|
|
32
32
|
commodity = dispatch.dispatch_plan_item.commodity
|
33
33
|
stacks = Stack.where(store: store, commodity: commodity)
|
34
|
-
if stacks.count
|
34
|
+
if stacks.count.zero?
|
35
35
|
errors.add(:store, "does not contain commodity #{commodity.batch_no}.")
|
36
36
|
return
|
37
37
|
end
|
@@ -44,8 +44,8 @@ module Cats
|
|
44
44
|
errors.add(:quantity, "exceeds available quantity in store by #{diff} #{unit.abbreviation}.") if diff.positive?
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.ransackable_attributes(
|
48
|
-
[
|
47
|
+
def self.ransackable_attributes(_auth_object = nil)
|
48
|
+
%w[authorized_by_id dispatch_id quantity status store_id unit_id]
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -67,12 +67,12 @@ module Cats
|
|
67
67
|
dispatchable.region.name
|
68
68
|
end
|
69
69
|
|
70
|
-
def self.ransackable_attributes(
|
71
|
-
[
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
def self.ransackable_attributes(_auth_object = nil)
|
71
|
+
%w[
|
72
|
+
approved_by_id
|
73
|
+
prepared_by_id
|
74
|
+
status
|
75
|
+
upstream
|
76
76
|
]
|
77
77
|
end
|
78
78
|
end
|
@@ -88,16 +88,16 @@ module Cats
|
|
88
88
|
)
|
89
89
|
end
|
90
90
|
|
91
|
-
def self.ransackable_attributes(
|
92
|
-
[
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
def self.ransackable_attributes(_auth_object = nil)
|
92
|
+
%w[
|
93
|
+
commodity_id
|
94
|
+
commodity_status
|
95
|
+
destination_id
|
96
|
+
dispatch_plan_id
|
97
|
+
quantity
|
98
|
+
source_id
|
99
|
+
status
|
100
|
+
unit_id
|
101
101
|
]
|
102
102
|
end
|
103
103
|
end
|
@@ -67,14 +67,14 @@ module Cats
|
|
67
67
|
![Dispatch::DRAFT, Dispatch::APPROVED].include?(dispatch_authorization.dispatch.dispatch_status)
|
68
68
|
end
|
69
69
|
|
70
|
-
def self.ransackable_attributes(
|
71
|
-
[
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
def self.ransackable_attributes(_auth_object = nil)
|
71
|
+
%w[
|
72
|
+
dispatch_authorization_id
|
73
|
+
quantity
|
74
|
+
source_id
|
75
|
+
status
|
76
|
+
transaction_date
|
77
|
+
unit_id
|
78
78
|
]
|
79
79
|
end
|
80
80
|
end
|