cats_core 1.5.17 → 1.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -7
- data/app/controllers/cats/core/access_controller.rb +4 -4
- data/app/controllers/cats/core/application_controller.rb +4 -4
- data/app/controllers/cats/core/commodities_controller.rb +7 -7
- data/app/controllers/cats/core/commodity_categories_controller.rb +4 -4
- data/app/controllers/cats/core/dispatch_authorizations_controller.rb +22 -9
- data/app/controllers/cats/core/dispatch_plan_items_controller.rb +4 -4
- data/app/controllers/cats/core/dispatch_plans_controller.rb +10 -10
- data/app/controllers/cats/core/dispatch_transactions_controller.rb +5 -5
- data/app/controllers/cats/core/dispatches_controller.rb +19 -19
- data/app/controllers/cats/core/loans_controller.rb +1 -1
- data/app/controllers/cats/core/locations_controller.rb +4 -4
- data/app/controllers/cats/core/menus_controller.rb +1 -1
- data/app/controllers/cats/core/notifications_controller.rb +5 -5
- data/app/controllers/cats/core/purchase_orders_controller.rb +3 -3
- data/app/controllers/cats/core/receipt_authorizations_controller.rb +29 -17
- data/app/controllers/cats/core/receipt_transactions_controller.rb +4 -4
- data/app/controllers/cats/core/receipts_controller.rb +1 -1
- data/app/controllers/cats/core/roles_controller.rb +3 -3
- data/app/controllers/cats/core/round_beneficiaries_controller.rb +13 -13
- data/app/controllers/cats/core/round_plans_controller.rb +13 -13
- data/app/controllers/cats/core/routes_controller.rb +2 -2
- data/app/controllers/cats/core/spaces_controller.rb +1 -1
- data/app/controllers/cats/core/stack_transactions_controller.rb +3 -3
- data/app/controllers/cats/core/stacks_controller.rb +15 -7
- data/app/controllers/cats/core/stores_controller.rb +14 -14
- data/app/controllers/cats/core/swaps_controller.rb +2 -2
- data/app/controllers/cats/core/transporters_controller.rb +1 -1
- data/app/controllers/cats/core/users_controller.rb +24 -12
- data/app/controllers/concerns/cats/core/common.rb +24 -23
- data/app/helpers/cats/core/document_helper.rb +1 -1
- data/app/models/cats/core/authorization.rb +9 -9
- data/app/models/cats/core/beneficiary.rb +6 -6
- data/app/models/cats/core/beneficiary_plan_item.rb +9 -9
- data/app/models/cats/core/beneficiary_round_plan_item.rb +2 -2
- data/app/models/cats/core/cash_donation.rb +1 -1
- data/app/models/cats/core/commodity.rb +47 -33
- data/app/models/cats/core/commodity_donation.rb +2 -2
- data/app/models/cats/core/commodity_substitution.rb +15 -7
- data/app/models/cats/core/contract_item.rb +2 -2
- data/app/models/cats/core/dispatch.rb +36 -21
- data/app/models/cats/core/dispatch_authorization.rb +31 -5
- data/app/models/cats/core/dispatch_plan.rb +19 -10
- data/app/models/cats/core/dispatch_plan_item.rb +27 -14
- data/app/models/cats/core/dispatch_transaction.rb +15 -5
- data/app/models/cats/core/gift_certificate.rb +3 -3
- data/app/models/cats/core/hub_authorization.rb +7 -7
- data/app/models/cats/core/loan.rb +2 -2
- data/app/models/cats/core/location.rb +12 -8
- data/app/models/cats/core/lost_commodity.rb +2 -2
- data/app/models/cats/core/notification.rb +2 -2
- data/app/models/cats/core/offer_item.rb +4 -4
- data/app/models/cats/core/plan.rb +9 -9
- data/app/models/cats/core/plan_item.rb +5 -5
- data/app/models/cats/core/plan_item_detail.rb +2 -2
- data/app/models/cats/core/project.rb +1 -1
- data/app/models/cats/core/purchase_order.rb +5 -5
- data/app/models/cats/core/ration.rb +1 -1
- data/app/models/cats/core/receipt.rb +5 -5
- data/app/models/cats/core/receipt_authorization.rb +6 -2
- data/app/models/cats/core/receipt_transaction.rb +8 -4
- data/app/models/cats/core/rhn_request.rb +8 -8
- data/app/models/cats/core/role_menu.rb +1 -1
- data/app/models/cats/core/round_beneficiary.rb +10 -2
- data/app/models/cats/core/round_plan.rb +15 -11
- data/app/models/cats/core/round_plan_item.rb +9 -5
- data/app/models/cats/core/round_plan_item_detail.rb +3 -3
- data/app/models/cats/core/round_ration.rb +2 -2
- data/app/models/cats/core/route.rb +12 -8
- data/app/models/cats/core/stack.rb +52 -34
- data/app/models/cats/core/stack_transaction.rb +3 -3
- data/app/models/cats/core/stacking_rule.rb +2 -2
- data/app/models/cats/core/store.rb +29 -7
- data/app/models/cats/core/swap.rb +5 -5
- data/app/models/cats/core/transaction.rb +6 -6
- data/app/models/cats/core/transport_bid.rb +13 -13
- data/app/models/cats/core/transport_bid_item.rb +2 -2
- data/app/models/cats/core/transport_offer.rb +3 -3
- data/app/models/cats/core/transport_order.rb +8 -8
- data/app/models/cats/core/transport_order_item.rb +2 -2
- data/app/models/cats/core/transport_plan.rb +7 -7
- data/app/models/cats/core/transport_plan_item.rb +2 -2
- data/app/models/cats/core/transport_requisition.rb +9 -9
- data/app/models/cats/core/transport_requisition_detail.rb +2 -2
- data/app/models/cats/core/transport_requisition_item.rb +3 -3
- data/app/models/cats/core/transporter.rb +4 -0
- data/app/models/cats/core/unit_conversion.rb +4 -4
- data/app/models/cats/core/unit_of_measure.rb +4 -4
- data/app/models/cats/core/user.rb +11 -11
- data/app/models/concerns/cats/core/dispatchable.rb +3 -3
- data/app/notifications/cats/core/allocation_notification.rb +1 -1
- data/app/notifications/cats/core/dispatch_authorization_notification.rb +5 -1
- data/app/notifications/cats/core/dispatch_notification.rb +1 -1
- data/app/notifications/cats/core/receipt_authorization_notification.rb +1 -1
- data/app/notifications/cats/core/round_plan_notification.rb +1 -1
- data/app/notifications/cats/core/simple_notification.rb +1 -1
- 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 +22 -21
- data/app/services/cats/core/beneficiary_service.rb +11 -11
- data/app/services/cats/core/dispatch_plan_service.rb +10 -10
- data/app/services/cats/core/dispatch_service.rb +31 -31
- data/app/services/cats/core/notification_service.rb +5 -5
- data/app/services/cats/core/round_plan_service.rb +23 -23
- data/app/services/cats/core/space_service.rb +11 -11
- data/app/services/cats/core/stack_service.rb +10 -10
- data/app/services/cats/core/token_auth_service.rb +4 -4
- data/app/services/cats/core/user_service.rb +19 -0
- data/app/utils/cats/core/util.rb +1 -1
- data/config/routes.rb +110 -105
- data/config/spring.rb +1 -0
- data/db/migrate/20210715114910_create_cats_core_users.rb +3 -3
- data/db/migrate/20210715120018_create_cats_core_roles.rb +14 -14
- 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 +13 -13
- data/db/migrate/20210717031810_create_cats_core_plans.rb +4 -4
- data/db/migrate/20210717032024_create_cats_core_plan_items.rb +18 -18
- data/db/migrate/20210717032260_create_cats_core_beneficiary_categories.rb +3 -3
- data/db/migrate/20210717032270_create_cats_core_rations.rb +10 -10
- 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 +10 -10
- data/db/migrate/20210717140855_create_cats_core_stores.rb +3 -3
- data/db/migrate/20210717171101_create_cats_core_stacks.rb +11 -11
- 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 +7 -7
- data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +17 -17
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +13 -13
- data/db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb +13 -13
- data/db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb +11 -11
- data/db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb +13 -13
- 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 +10 -10
- data/db/migrate/20210814175406_create_cats_core_stack_transactions.rb +10 -10
- data/db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb +1 -1
- data/db/migrate/20211030133752_add_status_to_cats_core_commodities.rb +1 -1
- data/db/migrate/20211215114737_create_cats_core_transport_plans.rb +4 -4
- data/db/migrate/20211215114835_create_cats_core_transport_plan_items.rb +9 -9
- data/db/migrate/20211215121151_create_cats_core_transport_bids.rb +4 -4
- data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +10 -10
- 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 +7 -7
- data/db/migrate/20220107122280_create_cats_core_round_rations.rb +12 -12
- data/db/migrate/20220107125025_create_cats_core_round_plan_items.rb +19 -19
- data/db/migrate/20220107126025_create_cats_core_beneficiary_round_plan_items.rb +8 -8
- 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 +6 -6
- 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 +10 -10
- data/db/migrate/20220506083042_create_cats_core_transport_order_items.rb +13 -13
- 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 +13 -13
- data/db/migrate/20220923190857_create_cats_core_application_settings.rb +3 -3
- data/lib/cats/core/engine.rb +4 -4
- data/lib/cats/core/version.rb +1 -1
- data/lib/cats_core.rb +8 -8
- data/spec/factories/cats/core/application_modules.rb +1 -1
- data/spec/factories/cats/core/application_settings.rb +1 -1
- data/spec/factories/cats/core/beneficiaries.rb +3 -3
- data/spec/factories/cats/core/beneficiary_categories.rb +1 -1
- data/spec/factories/cats/core/beneficiary_plan_items.rb +1 -1
- data/spec/factories/cats/core/beneficiary_round_plan_items.rb +1 -1
- data/spec/factories/cats/core/cash_donations.rb +1 -1
- data/spec/factories/cats/core/commodities.rb +1 -1
- data/spec/factories/cats/core/commodity_categories.rb +1 -1
- data/spec/factories/cats/core/commodity_donations.rb +1 -1
- data/spec/factories/cats/core/commodity_substitutions.rb +2 -2
- data/spec/factories/cats/core/contract_items.rb +1 -1
- data/spec/factories/cats/core/currencies.rb +1 -1
- data/spec/factories/cats/core/dispatch_authorizations.rb +7 -11
- data/spec/factories/cats/core/dispatch_plan_items.rb +16 -1
- data/spec/factories/cats/core/dispatch_plans.rb +1 -1
- data/spec/factories/cats/core/dispatch_transactions.rb +2 -4
- data/spec/factories/cats/core/dispatches.rb +16 -25
- data/spec/factories/cats/core/donors.rb +1 -1
- data/spec/factories/cats/core/gift_certificates.rb +1 -1
- data/spec/factories/cats/core/hub_authorizations.rb +1 -1
- data/spec/factories/cats/core/loans.rb +1 -1
- data/spec/factories/cats/core/locations.rb +6 -6
- data/spec/factories/cats/core/lost_commodities.rb +1 -1
- data/spec/factories/cats/core/menu_items.rb +1 -1
- data/spec/factories/cats/core/menus.rb +1 -1
- data/spec/factories/cats/core/notification_rules.rb +1 -1
- data/spec/factories/cats/core/notifications.rb +2 -2
- data/spec/factories/cats/core/offer_items.rb +1 -1
- data/spec/factories/cats/core/operators.rb +1 -1
- data/spec/factories/cats/core/plan_item_details.rb +1 -1
- data/spec/factories/cats/core/plan_items.rb +1 -1
- data/spec/factories/cats/core/plans.rb +1 -1
- data/spec/factories/cats/core/programs.rb +1 -1
- data/spec/factories/cats/core/projects.rb +1 -1
- data/spec/factories/cats/core/purchase_orders.rb +1 -1
- data/spec/factories/cats/core/rations.rb +1 -1
- data/spec/factories/cats/core/receipt_authorizations.rb +1 -1
- data/spec/factories/cats/core/receipt_transactions.rb +2 -2
- data/spec/factories/cats/core/receipts.rb +1 -1
- data/spec/factories/cats/core/rhn_requests.rb +1 -1
- data/spec/factories/cats/core/role_menus.rb +1 -1
- data/spec/factories/cats/core/roles.rb +1 -1
- data/spec/factories/cats/core/round_beneficiaries.rb +1 -1
- data/spec/factories/cats/core/round_plan_item_details.rb +3 -3
- data/spec/factories/cats/core/round_plan_items.rb +1 -1
- data/spec/factories/cats/core/round_plans.rb +1 -1
- data/spec/factories/cats/core/round_rations.rb +1 -1
- data/spec/factories/cats/core/routes.rb +1 -1
- data/spec/factories/cats/core/stack_transactions.rb +1 -1
- data/spec/factories/cats/core/stacking_rules.rb +1 -1
- data/spec/factories/cats/core/stacks.rb +1 -1
- data/spec/factories/cats/core/stores.rb +1 -1
- data/spec/factories/cats/core/suppliers.rb +1 -1
- data/spec/factories/cats/core/swaps.rb +1 -1
- data/spec/factories/cats/core/tenderers.rb +1 -1
- data/spec/factories/cats/core/transport_bid_items.rb +1 -1
- data/spec/factories/cats/core/transport_bids.rb +1 -1
- data/spec/factories/cats/core/transport_contracts.rb +1 -1
- data/spec/factories/cats/core/transport_offers.rb +1 -1
- data/spec/factories/cats/core/transport_order_items.rb +1 -1
- data/spec/factories/cats/core/transport_orders.rb +1 -1
- data/spec/factories/cats/core/transport_plan_items.rb +1 -1
- data/spec/factories/cats/core/transport_plans.rb +1 -1
- data/spec/factories/cats/core/transport_requisition_details.rb +1 -1
- data/spec/factories/cats/core/transport_requisition_items.rb +1 -1
- data/spec/factories/cats/core/transport_requisitions.rb +1 -1
- data/spec/factories/cats/core/transporters.rb +1 -1
- data/spec/factories/cats/core/unit_conversions.rb +1 -1
- data/spec/factories/cats/core/unit_of_measures.rb +1 -1
- data/spec/factories/cats/core/users.rb +2 -2
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0a7b1c5b85319ee7dbeee051bc4e934a0d37d0e7fc1605f0e15adbf5f0640e
|
4
|
+
data.tar.gz: 4eee6bb631559b0a984aa3b3feb55bd0668c8780ea95b066be7b8f705a4e67df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19064ad4da0b187b85339ebc515d0a210bd28159189cde3fd647a5d1b3f4f32ed71eb2fdd58c4cf4c58bb3d1c6f72d6f3370c485bb984bebb30565d7c1ef4e18
|
7
|
+
data.tar.gz: d497e8b77728f310660af1b684650cffe13f7294d613640a776de1df5ad69e3de021a7b8cf4b48a0a99c2a7ab0a7593d73695f65129c7735078f56773f7162bc
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/setup"
|
2
2
|
|
3
|
-
APP_RAKEFILE = File.expand_path(
|
4
|
-
load
|
3
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
4
|
+
load "rails/tasks/engine.rake"
|
5
5
|
|
6
|
-
load
|
6
|
+
load "rails/tasks/statistics.rake"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
RSpec::Core::RakeTask.new(spec:
|
8
|
+
require "bundler/gem_tasks"
|
9
|
+
require "rspec/core/rake_task"
|
10
|
+
RSpec::Core::RakeTask.new(spec: "app:db:test:prepare")
|
@@ -10,7 +10,7 @@ module Cats
|
|
10
10
|
roles = user.roles.map(&:name)
|
11
11
|
|
12
12
|
unless roles.count.positive?
|
13
|
-
render json: {
|
13
|
+
render json: {error: "User has no roles."}, status: :unprocessable_entity
|
14
14
|
return
|
15
15
|
end
|
16
16
|
|
@@ -19,12 +19,12 @@ module Cats
|
|
19
19
|
details: user.details
|
20
20
|
}
|
21
21
|
jwt = TokenAuthService.issue(payload)
|
22
|
-
render json: {
|
22
|
+
render json: {token: jwt, user: payload}
|
23
23
|
else
|
24
|
-
render json: {
|
24
|
+
render json: {error: "Invalid password."}, status: 400
|
25
25
|
end
|
26
26
|
else
|
27
|
-
render json: {
|
27
|
+
render json: {error: "User does not exist."}, status: 400
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -6,12 +6,12 @@ module Cats
|
|
6
6
|
def current_user
|
7
7
|
return if token.nil?
|
8
8
|
|
9
|
-
user = User.find(auth[
|
9
|
+
user = User.find(auth["id"])
|
10
10
|
@current_user ||= user
|
11
11
|
end
|
12
12
|
|
13
13
|
def authenticate
|
14
|
-
render json: {
|
14
|
+
render json: {error: "Unauthorized"}, status: 401 if current_user.nil?
|
15
15
|
end
|
16
16
|
|
17
17
|
# In case we want to disable bullet for specific controller actions
|
@@ -30,9 +30,9 @@ module Cats
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def token
|
33
|
-
return nil if request.env[
|
33
|
+
return nil if request.env["HTTP_AUTHORIZATION"].nil?
|
34
34
|
|
35
|
-
request.env[
|
35
|
+
request.env["HTTP_AUTHORIZATION"].scan(/Bearer (.*)$/).flatten.last
|
36
36
|
end
|
37
37
|
|
38
38
|
def auth
|
@@ -5,29 +5,29 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
Commodity.all.includes({
|
8
|
+
Commodity.all.includes({project: {source: :commodity_category}}, :unit_of_measure, :package_unit)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def approve
|
13
13
|
commodity = Commodity.find(params[:id])
|
14
14
|
result = commodity.approve
|
15
|
-
render json: {
|
16
|
-
rescue
|
17
|
-
render json: {
|
15
|
+
render json: {success: result, data: serialize(commodity)}
|
16
|
+
rescue => e
|
17
|
+
render json: {success: false, error: e.message}
|
18
18
|
end
|
19
19
|
|
20
20
|
def filter
|
21
21
|
query = Commodity.includes(:project, :unit_of_measure, :package_unit).ransack(params[:q])
|
22
|
-
render json: {
|
22
|
+
render json: {success: true, data: serialize(query.result)}
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
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
|
@@ -11,23 +11,23 @@ module Cats
|
|
11
11
|
|
12
12
|
def all
|
13
13
|
data = CommodityCategory.all
|
14
|
-
render json: {
|
14
|
+
render json: {success: true, data: data}
|
15
15
|
end
|
16
16
|
|
17
17
|
def root
|
18
18
|
data = CommodityCategory.roots
|
19
|
-
render json: {
|
19
|
+
render json: {success: true, data: serialize(data)}
|
20
20
|
end
|
21
21
|
|
22
22
|
def children
|
23
23
|
parent = CommodityCategory.find(params[:id])
|
24
|
-
render json: {
|
24
|
+
render json: {success: true, data: serialize(parent.children)}
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def model_params
|
30
|
-
params.require(
|
30
|
+
params.require("payload").permit(:code, :name, :description, :parent_id)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -5,7 +5,9 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
DispatchAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(
|
8
|
+
DispatchAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(
|
9
|
+
dispatch_id: params[:id]
|
10
|
+
).reverse_order
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -13,27 +15,38 @@ module Cats
|
|
13
15
|
authorization = DispatchAuthorization.new(model_params)
|
14
16
|
if authorization.save
|
15
17
|
AuthorizationService.new.send_dispatch_notification(authorization)
|
16
|
-
render json: {
|
18
|
+
render json: {success: true, data: serialize(authorization)}, status: :created
|
17
19
|
else
|
18
|
-
render json: {
|
20
|
+
render json: {success: false, error: authorization.errors.full_messages[0]}, status: :unprocessable_entity
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def confirm
|
23
25
|
authorization = DispatchAuthorization.find(params[:id])
|
24
26
|
authorization = authorization.confirm
|
25
|
-
render json: {
|
26
|
-
rescue
|
27
|
-
render json: {
|
27
|
+
render json: {success: true, data: serialize(authorization)}
|
28
|
+
rescue => e
|
29
|
+
render json: {success: false, error: e.message}
|
28
30
|
end
|
29
31
|
|
30
32
|
def storekeeper_authorizations
|
31
33
|
storekeeper = User.find(params[:id])
|
32
34
|
stores = storekeeper.stores
|
33
35
|
authorizations = DispatchAuthorization.joins(:dispatch)
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
.includes(:dispatch, :store, :authorized_by, :unit)
|
37
|
+
.where(store: stores, dispatch: {dispatch_status: Dispatch::APPROVED})
|
38
|
+
.reverse_order
|
39
|
+
render json: {success: true, data: serialize(authorizations)}
|
40
|
+
end
|
41
|
+
|
42
|
+
def filter
|
43
|
+
query = DispatchAuthorization.includes(
|
44
|
+
:dispatch,
|
45
|
+
:store,
|
46
|
+
:authorized_by,
|
47
|
+
:unit
|
48
|
+
).ransack(params[:q])
|
49
|
+
render json: {success: true, data: serialize(query.result.reverse_order)}
|
37
50
|
end
|
38
51
|
|
39
52
|
private
|
@@ -8,7 +8,7 @@ module Cats
|
|
8
8
|
DispatchPlanItem.includes(
|
9
9
|
:source,
|
10
10
|
:destination,
|
11
|
-
{
|
11
|
+
{commodity: {project: {source: :commodity_category}}},
|
12
12
|
:unit,
|
13
13
|
:dispatch_plan
|
14
14
|
).where(dispatch_plan_id: params[:id])
|
@@ -19,18 +19,18 @@ module Cats
|
|
19
19
|
query = DispatchPlanItem.includes(
|
20
20
|
:source,
|
21
21
|
:destination,
|
22
|
-
{
|
22
|
+
{commodity: {project: {source: :commodity_category}}},
|
23
23
|
:unit,
|
24
24
|
:dispatch_plan
|
25
25
|
).ransack(params[:q])
|
26
|
-
render json: {
|
26
|
+
render json: {success: true, data: serialize(query.result)}
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
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
|
@@ -11,41 +11,41 @@ module Cats
|
|
11
11
|
|
12
12
|
def plans_for_user
|
13
13
|
plans = DispatchPlan.where(prepared_by: current_user).includes(:dispatchable)
|
14
|
-
render json: {
|
14
|
+
render json: {success: true, data: serialize(plans)}
|
15
15
|
end
|
16
16
|
|
17
17
|
def filter
|
18
18
|
query = DispatchPlan.ransack(params[:q])
|
19
|
-
render json: {
|
19
|
+
render json: {success: true, data: serialize(query.result)}
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
23
|
service = DispatchPlanService.new
|
24
24
|
plan = service.create(model_params, current_user)
|
25
|
-
render json: {
|
26
|
-
rescue
|
27
|
-
render json: {
|
25
|
+
render json: {success: true, data: serialize(plan)}, status: :created
|
26
|
+
rescue => e
|
27
|
+
render json: {success: false, error: e.message}, status: :unprocessable_entity
|
28
28
|
end
|
29
29
|
|
30
30
|
def generate
|
31
31
|
service = DispatchPlanService.new
|
32
32
|
items = service.generate(params[:id])
|
33
|
-
render json: {
|
33
|
+
render json: {success: true, data: serialize(items)}
|
34
34
|
end
|
35
35
|
|
36
36
|
def bulk_create
|
37
37
|
service = DispatchPlanService.new
|
38
38
|
plan = service.bulk_create(bulk_create_params, current_user)
|
39
|
-
render json: {
|
39
|
+
render json: {success: true, data: serialize(plan)}
|
40
40
|
end
|
41
41
|
|
42
42
|
def approve
|
43
43
|
service = DispatchPlanService.new
|
44
44
|
plan = DispatchPlan.find(params[:id])
|
45
45
|
plan = service.approve(plan)
|
46
|
-
render json: {
|
47
|
-
rescue
|
48
|
-
render json: {
|
46
|
+
render json: {success: true, data: serialize(plan)}
|
47
|
+
rescue => e
|
48
|
+
render json: {success: false, error: e.message}
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
@@ -19,26 +19,26 @@ module Cats
|
|
19
19
|
transaction = DispatchTransaction.new(model_params)
|
20
20
|
|
21
21
|
# Fetch supplier stack by commodity
|
22
|
-
stack = Stack.joins(:store).find_by(commodity: commodity, store: {
|
22
|
+
stack = Stack.joins(:store).find_by(commodity: commodity, store: {code: "SUP-STORE"})
|
23
23
|
transaction.source = stack
|
24
24
|
|
25
25
|
if transaction.save
|
26
|
-
render json: {
|
26
|
+
render json: {success: true, data: serialize(transaction)}, status: :created
|
27
27
|
else
|
28
|
-
render json: {
|
28
|
+
render json: {success: false, error: transaction.errors.full_messages[0]}, status: :unprocessable_entity
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def filter
|
33
33
|
query = DispatchTransaction.ransack(params[:q])
|
34
|
-
render json: {
|
34
|
+
render json: {success: true, data: serialize(query.result)}
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def model_params
|
40
40
|
params.require(:payload).permit(:source_id, :dispatch_authorization_id, :transaction_date, :quantity, :unit_id,
|
41
|
-
|
41
|
+
:reference_no)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -9,11 +9,11 @@ module Cats
|
|
9
9
|
def index
|
10
10
|
super do
|
11
11
|
Dispatch.includes(
|
12
|
-
{
|
12
|
+
{dispatch_plan_item: :destination},
|
13
13
|
:transporter,
|
14
14
|
:prepared_by,
|
15
15
|
:unit
|
16
|
-
).where(dispatch_plan_item_id: params[:id])
|
16
|
+
).where(dispatch_plan_item_id: params[:id]).reverse_order
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -29,51 +29,51 @@ module Cats
|
|
29
29
|
def approve
|
30
30
|
dispatch = set_object
|
31
31
|
dispatch.approve
|
32
|
-
render json: {
|
33
|
-
rescue
|
34
|
-
render json: {
|
32
|
+
render json: {success: true, data: serialize(dispatch)}
|
33
|
+
rescue => e
|
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
|
-
render json: {
|
40
|
-
rescue
|
41
|
-
render json: {
|
39
|
+
render json: {success: true, data: serialize(dispatch)}
|
40
|
+
rescue => e
|
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
|
-
render json: {
|
47
|
-
rescue
|
48
|
-
render json: {
|
46
|
+
render json: {success: true, data: serialize(dispatch)}
|
47
|
+
rescue => e
|
48
|
+
render json: {success: false, error: e.message}
|
49
49
|
end
|
50
50
|
|
51
51
|
def confirm
|
52
52
|
dispatch = set_object
|
53
53
|
dispatch.confirm
|
54
|
-
render json: {
|
55
|
-
rescue
|
56
|
-
render json: {
|
54
|
+
render json: {success: true, data: serialize(dispatch)}
|
55
|
+
rescue => e
|
56
|
+
render json: {success: false, error: e.message}
|
57
57
|
end
|
58
58
|
|
59
59
|
def filter
|
60
60
|
query = Dispatch.includes(
|
61
|
-
{
|
61
|
+
{dispatch_plan_item: :destination},
|
62
62
|
:transporter,
|
63
63
|
:prepared_by,
|
64
64
|
:unit
|
65
65
|
).ransack(params[:q])
|
66
|
-
render json: {
|
66
|
+
render json: {success: true, data: serialize(query.result.reverse_order)}
|
67
67
|
end
|
68
68
|
|
69
69
|
def search
|
70
70
|
data = @service.search(current_user, params[:status])
|
71
|
-
render json: {
|
71
|
+
render json: {success: true, data: serialize(data)}
|
72
72
|
end
|
73
73
|
|
74
74
|
def commodity
|
75
75
|
data = set_object.dispatch_plan_item.commodity
|
76
|
-
render json: {
|
76
|
+
render json: {success: true, data: serialize(data)}
|
77
77
|
end
|
78
78
|
|
79
79
|
private
|
@@ -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
|
@@ -11,25 +11,25 @@ module Cats
|
|
11
11
|
|
12
12
|
def children
|
13
13
|
parent = Location.find(params[:id])
|
14
|
-
render json: {
|
14
|
+
render json: {success: true, data: serialize(parent.children)}
|
15
15
|
end
|
16
16
|
|
17
17
|
def filter
|
18
18
|
query = Location.ransack(params[:q])
|
19
|
-
render json: {
|
19
|
+
render json: {success: true, data: serialize(query.result)}
|
20
20
|
end
|
21
21
|
|
22
22
|
def woredas
|
23
23
|
region = Location.find(params[:id])
|
24
24
|
woredas = Location.where(id: region.descendant_ids, location_type: Location::WOREDA)
|
25
|
-
render json: {
|
25
|
+
render json: {success: true, data: serialize(woredas)}
|
26
26
|
end
|
27
27
|
|
28
28
|
def create_fdp
|
29
29
|
service = LocationService.new
|
30
30
|
p = fdp_params
|
31
31
|
fdp = service.create_fdp(p[:code], p[:name], p[:parent_id], p[:description])
|
32
|
-
render json: {
|
32
|
+
render json: {success: true, data: serialize(fdp)}
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
@@ -6,7 +6,7 @@ module Cats
|
|
6
6
|
def index
|
7
7
|
menu = @service.fetch_menu(current_user)
|
8
8
|
data = ActiveModelSerializers::SerializableResource.new(menu, each_serializer: RoleMenuSerializer)
|
9
|
-
render json: {
|
9
|
+
render json: {success: true, data: data}
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -5,27 +5,27 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
data = Notification.messages(current_user.notifications.newest_first)
|
8
|
-
render json: {
|
8
|
+
render json: {success: true, data: data}
|
9
9
|
end
|
10
10
|
|
11
11
|
def read
|
12
12
|
data = Notification.messages(current_user.notifications.read.newest_first)
|
13
|
-
render json: {
|
13
|
+
render json: {success: true, data: data}
|
14
14
|
end
|
15
15
|
|
16
16
|
def unread
|
17
17
|
data = Notification.messages(current_user.notifications.unread.newest_first)
|
18
|
-
render json: {
|
18
|
+
render json: {success: true, data: data}
|
19
19
|
end
|
20
20
|
|
21
21
|
def mark_as_read
|
22
22
|
@notification.mark_as_read!
|
23
|
-
render json: {
|
23
|
+
render json: {success: true, data: @notification.message}
|
24
24
|
end
|
25
25
|
|
26
26
|
def mark_as_unread
|
27
27
|
@notification.mark_as_unread!
|
28
|
-
render json: {
|
28
|
+
render json: {success: true, data: @notification.message}
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -9,15 +9,15 @@ module Cats
|
|
9
9
|
:unit,
|
10
10
|
:currency
|
11
11
|
)
|
12
|
-
render json: {
|
12
|
+
render json: {success: true, data: serialize(purchase_orders)}
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
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
|
@@ -7,7 +7,7 @@ module Cats
|
|
7
7
|
|
8
8
|
def index
|
9
9
|
super do
|
10
|
-
ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(dispatch_id: params[:id])
|
10
|
+
ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit).where(dispatch_id: params[:id]).reverse_order
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,35 +15,37 @@ module Cats
|
|
15
15
|
authorization = ReceiptAuthorization.new(model_params)
|
16
16
|
if authorization.save
|
17
17
|
AuthorizationService.new.send_receipt_notification(authorization)
|
18
|
-
render json: {
|
18
|
+
render json: {success: true, data: serialize(authorization)}, status: :created
|
19
19
|
else
|
20
|
-
render json: {
|
20
|
+
render json: {success: false, error: authorization.errors.full_messages[0]}, status: :unprocessable_entity
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def confirm
|
25
25
|
authorization = ReceiptAuthorization.find(params[:id])
|
26
26
|
authorization.confirm
|
27
|
-
render json: {
|
28
|
-
rescue
|
29
|
-
render json: {
|
27
|
+
render json: {success: true, data: serialize(authorization)}
|
28
|
+
rescue => e
|
29
|
+
render json: {success: false, error: e.message}
|
30
30
|
end
|
31
31
|
|
32
32
|
def driver_confirm
|
33
33
|
service = AuthorizationService.new
|
34
|
-
authorization = service.driver_confirm(
|
35
|
-
|
36
|
-
|
37
|
-
render json: {
|
34
|
+
authorization = service.driver_confirm(
|
35
|
+
params[:id], driver_confirm_params[:pin], driver_confirm_params[:receipt_number]
|
36
|
+
)
|
37
|
+
render json: {success: true, data: serialize(authorization)}
|
38
|
+
rescue => e
|
39
|
+
render json: {success: false, error: e.message}
|
38
40
|
end
|
39
41
|
|
40
42
|
def stack
|
41
43
|
service = AuthorizationService.new
|
42
44
|
authorization = ReceiptAuthorization.find(params[:id])
|
43
45
|
authorization = service.stack(authorization.id)
|
44
|
-
render json: {
|
45
|
-
rescue
|
46
|
-
render json: {
|
46
|
+
render json: {success: true, data: serialize(authorization)}
|
47
|
+
rescue => e
|
48
|
+
render json: {success: false, error: e.message}
|
47
49
|
end
|
48
50
|
|
49
51
|
def storekeeper_authorizations
|
@@ -51,19 +53,29 @@ module Cats
|
|
51
53
|
status = params[:status]
|
52
54
|
stores = storekeeper.stores
|
53
55
|
authorizations = ReceiptAuthorization.includes(:dispatch, :store, :authorized_by, :unit)
|
54
|
-
|
55
|
-
render json: {
|
56
|
+
.where(store: stores, status: status)
|
57
|
+
render json: {success: true, data: serialize(authorizations)}
|
58
|
+
end
|
59
|
+
|
60
|
+
def filter
|
61
|
+
query = ReceiptAuthorization.includes(
|
62
|
+
:dispatch,
|
63
|
+
:store,
|
64
|
+
:authorized_by,
|
65
|
+
:unit
|
66
|
+
).ransack(params[:q])
|
67
|
+
render json: {success: true, data: serialize(query.result.reverse_order)}
|
56
68
|
end
|
57
69
|
|
58
70
|
private
|
59
71
|
|
60
72
|
def model_params
|
61
73
|
params.require(:payload).permit(:dispatch_id, :store_id, :quantity, :unit_id, :remark, :status,
|
62
|
-
|
74
|
+
:authorized_by_id)
|
63
75
|
end
|
64
76
|
|
65
77
|
def driver_confirm_params
|
66
|
-
params.require(:payload).permit(:pin)
|
78
|
+
params.require(:payload).permit(:pin, :receipt_number)
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
@@ -5,21 +5,21 @@ module Cats
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
super do
|
8
|
-
ReceiptTransaction.includes(:destination, {
|
9
|
-
|
8
|
+
ReceiptTransaction.includes(:destination, {receipt_authorization: :dispatch}, :unit)
|
9
|
+
.where(receipt_authorization_id: params[:id])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def filter
|
14
14
|
query = ReceiptTransaction.ransack(params[:q])
|
15
|
-
render json: {
|
15
|
+
render json: {success: true, data: serialize(query.result)}
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
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
|