cats_core 1.5.17 → 1.5.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -7
  3. data/app/controllers/cats/core/access_controller.rb +4 -4
  4. data/app/controllers/cats/core/application_controller.rb +4 -4
  5. data/app/controllers/cats/core/commodities_controller.rb +7 -7
  6. data/app/controllers/cats/core/commodity_categories_controller.rb +4 -4
  7. data/app/controllers/cats/core/dispatch_authorizations_controller.rb +22 -9
  8. data/app/controllers/cats/core/dispatch_plan_items_controller.rb +4 -4
  9. data/app/controllers/cats/core/dispatch_plans_controller.rb +10 -10
  10. data/app/controllers/cats/core/dispatch_transactions_controller.rb +5 -5
  11. data/app/controllers/cats/core/dispatches_controller.rb +19 -19
  12. data/app/controllers/cats/core/loans_controller.rb +1 -1
  13. data/app/controllers/cats/core/locations_controller.rb +4 -4
  14. data/app/controllers/cats/core/menus_controller.rb +1 -1
  15. data/app/controllers/cats/core/notifications_controller.rb +5 -5
  16. data/app/controllers/cats/core/purchase_orders_controller.rb +3 -3
  17. data/app/controllers/cats/core/receipt_authorizations_controller.rb +29 -17
  18. data/app/controllers/cats/core/receipt_transactions_controller.rb +4 -4
  19. data/app/controllers/cats/core/receipts_controller.rb +1 -1
  20. data/app/controllers/cats/core/roles_controller.rb +3 -3
  21. data/app/controllers/cats/core/round_beneficiaries_controller.rb +13 -13
  22. data/app/controllers/cats/core/round_plans_controller.rb +13 -13
  23. data/app/controllers/cats/core/routes_controller.rb +2 -2
  24. data/app/controllers/cats/core/spaces_controller.rb +1 -1
  25. data/app/controllers/cats/core/stack_transactions_controller.rb +3 -3
  26. data/app/controllers/cats/core/stacks_controller.rb +15 -7
  27. data/app/controllers/cats/core/stores_controller.rb +14 -14
  28. data/app/controllers/cats/core/swaps_controller.rb +2 -2
  29. data/app/controllers/cats/core/transporters_controller.rb +1 -1
  30. data/app/controllers/cats/core/users_controller.rb +24 -12
  31. data/app/controllers/concerns/cats/core/common.rb +24 -23
  32. data/app/helpers/cats/core/document_helper.rb +1 -1
  33. data/app/models/cats/core/authorization.rb +9 -9
  34. data/app/models/cats/core/beneficiary.rb +6 -6
  35. data/app/models/cats/core/beneficiary_plan_item.rb +9 -9
  36. data/app/models/cats/core/beneficiary_round_plan_item.rb +2 -2
  37. data/app/models/cats/core/cash_donation.rb +1 -1
  38. data/app/models/cats/core/commodity.rb +47 -33
  39. data/app/models/cats/core/commodity_donation.rb +2 -2
  40. data/app/models/cats/core/commodity_substitution.rb +15 -7
  41. data/app/models/cats/core/contract_item.rb +2 -2
  42. data/app/models/cats/core/dispatch.rb +36 -21
  43. data/app/models/cats/core/dispatch_authorization.rb +31 -5
  44. data/app/models/cats/core/dispatch_plan.rb +19 -10
  45. data/app/models/cats/core/dispatch_plan_item.rb +27 -14
  46. data/app/models/cats/core/dispatch_transaction.rb +15 -5
  47. data/app/models/cats/core/gift_certificate.rb +3 -3
  48. data/app/models/cats/core/hub_authorization.rb +7 -7
  49. data/app/models/cats/core/loan.rb +2 -2
  50. data/app/models/cats/core/location.rb +12 -8
  51. data/app/models/cats/core/lost_commodity.rb +2 -2
  52. data/app/models/cats/core/notification.rb +2 -2
  53. data/app/models/cats/core/offer_item.rb +4 -4
  54. data/app/models/cats/core/plan.rb +9 -9
  55. data/app/models/cats/core/plan_item.rb +5 -5
  56. data/app/models/cats/core/plan_item_detail.rb +2 -2
  57. data/app/models/cats/core/project.rb +1 -1
  58. data/app/models/cats/core/purchase_order.rb +5 -5
  59. data/app/models/cats/core/ration.rb +1 -1
  60. data/app/models/cats/core/receipt.rb +5 -5
  61. data/app/models/cats/core/receipt_authorization.rb +6 -2
  62. data/app/models/cats/core/receipt_transaction.rb +8 -4
  63. data/app/models/cats/core/rhn_request.rb +8 -8
  64. data/app/models/cats/core/role_menu.rb +1 -1
  65. data/app/models/cats/core/round_beneficiary.rb +10 -2
  66. data/app/models/cats/core/round_plan.rb +15 -11
  67. data/app/models/cats/core/round_plan_item.rb +9 -5
  68. data/app/models/cats/core/round_plan_item_detail.rb +3 -3
  69. data/app/models/cats/core/round_ration.rb +2 -2
  70. data/app/models/cats/core/route.rb +12 -8
  71. data/app/models/cats/core/stack.rb +52 -34
  72. data/app/models/cats/core/stack_transaction.rb +3 -3
  73. data/app/models/cats/core/stacking_rule.rb +2 -2
  74. data/app/models/cats/core/store.rb +29 -7
  75. data/app/models/cats/core/swap.rb +5 -5
  76. data/app/models/cats/core/transaction.rb +6 -6
  77. data/app/models/cats/core/transport_bid.rb +13 -13
  78. data/app/models/cats/core/transport_bid_item.rb +2 -2
  79. data/app/models/cats/core/transport_offer.rb +3 -3
  80. data/app/models/cats/core/transport_order.rb +8 -8
  81. data/app/models/cats/core/transport_order_item.rb +2 -2
  82. data/app/models/cats/core/transport_plan.rb +7 -7
  83. data/app/models/cats/core/transport_plan_item.rb +2 -2
  84. data/app/models/cats/core/transport_requisition.rb +9 -9
  85. data/app/models/cats/core/transport_requisition_detail.rb +2 -2
  86. data/app/models/cats/core/transport_requisition_item.rb +3 -3
  87. data/app/models/cats/core/transporter.rb +4 -0
  88. data/app/models/cats/core/unit_conversion.rb +4 -4
  89. data/app/models/cats/core/unit_of_measure.rb +4 -4
  90. data/app/models/cats/core/user.rb +11 -11
  91. data/app/models/concerns/cats/core/dispatchable.rb +3 -3
  92. data/app/notifications/cats/core/allocation_notification.rb +1 -1
  93. data/app/notifications/cats/core/dispatch_authorization_notification.rb +5 -1
  94. data/app/notifications/cats/core/dispatch_notification.rb +1 -1
  95. data/app/notifications/cats/core/receipt_authorization_notification.rb +1 -1
  96. data/app/notifications/cats/core/round_plan_notification.rb +1 -1
  97. data/app/notifications/cats/core/simple_notification.rb +1 -1
  98. data/app/serializers/cats/core/cash_donation_serializer.rb +1 -1
  99. data/app/serializers/cats/core/commodity_donation_serializer.rb +2 -2
  100. data/app/serializers/cats/core/commodity_serializer.rb +2 -2
  101. data/app/serializers/cats/core/dispatch_authorization_serializer.rb +2 -2
  102. data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +3 -3
  103. data/app/serializers/cats/core/dispatch_plan_serializer.rb +1 -1
  104. data/app/serializers/cats/core/dispatch_serializer.rb +2 -2
  105. data/app/serializers/cats/core/dispatch_transaction_serializer.rb +1 -1
  106. data/app/serializers/cats/core/loan_serializer.rb +1 -1
  107. data/app/serializers/cats/core/purchase_order_serializer.rb +2 -2
  108. data/app/serializers/cats/core/receipt_authorization_serializer.rb +2 -2
  109. data/app/serializers/cats/core/receipt_serializer.rb +1 -1
  110. data/app/serializers/cats/core/receipt_transaction_serializer.rb +2 -2
  111. data/app/serializers/cats/core/round_beneficiary_serializer.rb +1 -1
  112. data/app/serializers/cats/core/round_plan_serializer.rb +1 -1
  113. data/app/serializers/cats/core/stack_serializer.rb +1 -1
  114. data/app/serializers/cats/core/store_serializer.rb +1 -1
  115. data/app/serializers/cats/core/swap_serializer.rb +2 -2
  116. data/app/services/cats/core/authorization_service.rb +22 -21
  117. data/app/services/cats/core/beneficiary_service.rb +11 -11
  118. data/app/services/cats/core/dispatch_plan_service.rb +10 -10
  119. data/app/services/cats/core/dispatch_service.rb +31 -31
  120. data/app/services/cats/core/notification_service.rb +5 -5
  121. data/app/services/cats/core/round_plan_service.rb +23 -23
  122. data/app/services/cats/core/space_service.rb +11 -11
  123. data/app/services/cats/core/stack_service.rb +10 -10
  124. data/app/services/cats/core/token_auth_service.rb +4 -4
  125. data/app/services/cats/core/user_service.rb +19 -0
  126. data/app/utils/cats/core/util.rb +1 -1
  127. data/config/routes.rb +110 -105
  128. data/config/spring.rb +1 -0
  129. data/db/migrate/20210715114910_create_cats_core_users.rb +3 -3
  130. data/db/migrate/20210715120018_create_cats_core_roles.rb +14 -14
  131. data/db/migrate/20210715121244_create_cats_core_menus.rb +3 -3
  132. data/db/migrate/20210715122141_create_cats_core_menu_items.rb +3 -3
  133. data/db/migrate/20210715122423_create_cats_core_role_menus.rb +13 -13
  134. data/db/migrate/20210717031810_create_cats_core_plans.rb +4 -4
  135. data/db/migrate/20210717032024_create_cats_core_plan_items.rb +18 -18
  136. data/db/migrate/20210717032260_create_cats_core_beneficiary_categories.rb +3 -3
  137. data/db/migrate/20210717032270_create_cats_core_rations.rb +10 -10
  138. data/db/migrate/20210717032290_create_cats_core_beneficiary_plan_items.rb +7 -7
  139. data/db/migrate/20210717032295_create_cats_core_plan_item_details.rb +7 -7
  140. data/db/migrate/20210717032330_create_cats_core_commodity_donations.rb +12 -12
  141. data/db/migrate/20210717032408_create_cats_core_cash_donations.rb +6 -6
  142. data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +12 -12
  143. data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +12 -12
  144. data/db/migrate/20210717032927_create_cats_core_projects.rb +3 -3
  145. data/db/migrate/20210717033223_create_cats_core_commodities.rb +10 -10
  146. data/db/migrate/20210717140855_create_cats_core_stores.rb +3 -3
  147. data/db/migrate/20210717171101_create_cats_core_stacks.rb +11 -11
  148. data/db/migrate/20210718040129_create_cats_core_routes.rb +9 -9
  149. data/db/migrate/20210718042755_create_cats_core_rhn_requests.rb +6 -6
  150. data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +7 -7
  151. data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +17 -17
  152. data/db/migrate/20210718045516_create_cats_core_dispatches.rb +13 -13
  153. data/db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb +13 -13
  154. data/db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb +11 -11
  155. data/db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb +13 -13
  156. data/db/migrate/20210727105834_create_cats_core_receipts.rb +6 -6
  157. data/db/migrate/20210728041505_create_cats_core_lost_commodities.rb +6 -6
  158. data/db/migrate/20210814160628_create_cats_core_receipt_transactions.rb +10 -10
  159. data/db/migrate/20210814175406_create_cats_core_stack_transactions.rb +10 -10
  160. data/db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb +1 -1
  161. data/db/migrate/20211030133752_add_status_to_cats_core_commodities.rb +1 -1
  162. data/db/migrate/20211215114737_create_cats_core_transport_plans.rb +4 -4
  163. data/db/migrate/20211215114835_create_cats_core_transport_plan_items.rb +9 -9
  164. data/db/migrate/20211215121151_create_cats_core_transport_bids.rb +4 -4
  165. data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +10 -10
  166. data/db/migrate/20211229160125_create_cats_core_transport_offers.rb +7 -7
  167. data/db/migrate/20211229160126_create_cats_core_offer_items.rb +6 -6
  168. data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +6 -6
  169. data/db/migrate/20211229160128_create_cats_core_contract_items.rb +9 -9
  170. data/db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb +10 -10
  171. data/db/migrate/20220103152802_create_cats_core_tenderers.rb +6 -6
  172. data/db/migrate/20220107121752_create_cats_core_round_plans.rb +7 -7
  173. data/db/migrate/20220107122280_create_cats_core_round_rations.rb +12 -12
  174. data/db/migrate/20220107125025_create_cats_core_round_plan_items.rb +19 -19
  175. data/db/migrate/20220107126025_create_cats_core_beneficiary_round_plan_items.rb +8 -8
  176. data/db/migrate/20220107132433_create_cats_core_round_plan_item_details.rb +9 -9
  177. data/db/migrate/20220209083928_create_cats_core_hub_authorizations.rb +12 -12
  178. data/db/migrate/20220416143416_create_cats_core_unit_conversions.rb +6 -6
  179. data/db/migrate/20220417105839_create_cats_core_transport_requisitions.rb +12 -12
  180. data/db/migrate/20220417123835_create_cats_core_transport_requisition_items.rb +9 -9
  181. data/db/migrate/20220417151821_create_cats_core_transport_requisition_details.rb +6 -6
  182. data/db/migrate/20220506082329_create_cats_core_transport_orders.rb +10 -10
  183. data/db/migrate/20220506083042_create_cats_core_transport_order_items.rb +13 -13
  184. data/db/migrate/20220511082354_create_cats_core_beneficiaries.rb +6 -6
  185. data/db/migrate/20220626063501_create_cats_core_loans.rb +6 -6
  186. data/db/migrate/20220626063757_create_cats_core_swaps.rb +12 -12
  187. data/db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb +13 -13
  188. data/db/migrate/20220923190857_create_cats_core_application_settings.rb +3 -3
  189. data/lib/cats/core/engine.rb +4 -4
  190. data/lib/cats/core/version.rb +1 -1
  191. data/lib/cats_core.rb +8 -8
  192. data/spec/factories/cats/core/application_modules.rb +1 -1
  193. data/spec/factories/cats/core/application_settings.rb +1 -1
  194. data/spec/factories/cats/core/beneficiaries.rb +3 -3
  195. data/spec/factories/cats/core/beneficiary_categories.rb +1 -1
  196. data/spec/factories/cats/core/beneficiary_plan_items.rb +1 -1
  197. data/spec/factories/cats/core/beneficiary_round_plan_items.rb +1 -1
  198. data/spec/factories/cats/core/cash_donations.rb +1 -1
  199. data/spec/factories/cats/core/commodities.rb +1 -1
  200. data/spec/factories/cats/core/commodity_categories.rb +1 -1
  201. data/spec/factories/cats/core/commodity_donations.rb +1 -1
  202. data/spec/factories/cats/core/commodity_substitutions.rb +2 -2
  203. data/spec/factories/cats/core/contract_items.rb +1 -1
  204. data/spec/factories/cats/core/currencies.rb +1 -1
  205. data/spec/factories/cats/core/dispatch_authorizations.rb +7 -11
  206. data/spec/factories/cats/core/dispatch_plan_items.rb +16 -1
  207. data/spec/factories/cats/core/dispatch_plans.rb +1 -1
  208. data/spec/factories/cats/core/dispatch_transactions.rb +2 -4
  209. data/spec/factories/cats/core/dispatches.rb +16 -25
  210. data/spec/factories/cats/core/donors.rb +1 -1
  211. data/spec/factories/cats/core/gift_certificates.rb +1 -1
  212. data/spec/factories/cats/core/hub_authorizations.rb +1 -1
  213. data/spec/factories/cats/core/loans.rb +1 -1
  214. data/spec/factories/cats/core/locations.rb +6 -6
  215. data/spec/factories/cats/core/lost_commodities.rb +1 -1
  216. data/spec/factories/cats/core/menu_items.rb +1 -1
  217. data/spec/factories/cats/core/menus.rb +1 -1
  218. data/spec/factories/cats/core/notification_rules.rb +1 -1
  219. data/spec/factories/cats/core/notifications.rb +2 -2
  220. data/spec/factories/cats/core/offer_items.rb +1 -1
  221. data/spec/factories/cats/core/operators.rb +1 -1
  222. data/spec/factories/cats/core/plan_item_details.rb +1 -1
  223. data/spec/factories/cats/core/plan_items.rb +1 -1
  224. data/spec/factories/cats/core/plans.rb +1 -1
  225. data/spec/factories/cats/core/programs.rb +1 -1
  226. data/spec/factories/cats/core/projects.rb +1 -1
  227. data/spec/factories/cats/core/purchase_orders.rb +1 -1
  228. data/spec/factories/cats/core/rations.rb +1 -1
  229. data/spec/factories/cats/core/receipt_authorizations.rb +1 -1
  230. data/spec/factories/cats/core/receipt_transactions.rb +2 -2
  231. data/spec/factories/cats/core/receipts.rb +1 -1
  232. data/spec/factories/cats/core/rhn_requests.rb +1 -1
  233. data/spec/factories/cats/core/role_menus.rb +1 -1
  234. data/spec/factories/cats/core/roles.rb +1 -1
  235. data/spec/factories/cats/core/round_beneficiaries.rb +1 -1
  236. data/spec/factories/cats/core/round_plan_item_details.rb +3 -3
  237. data/spec/factories/cats/core/round_plan_items.rb +1 -1
  238. data/spec/factories/cats/core/round_plans.rb +1 -1
  239. data/spec/factories/cats/core/round_rations.rb +1 -1
  240. data/spec/factories/cats/core/routes.rb +1 -1
  241. data/spec/factories/cats/core/stack_transactions.rb +1 -1
  242. data/spec/factories/cats/core/stacking_rules.rb +1 -1
  243. data/spec/factories/cats/core/stacks.rb +1 -1
  244. data/spec/factories/cats/core/stores.rb +1 -1
  245. data/spec/factories/cats/core/suppliers.rb +1 -1
  246. data/spec/factories/cats/core/swaps.rb +1 -1
  247. data/spec/factories/cats/core/tenderers.rb +1 -1
  248. data/spec/factories/cats/core/transport_bid_items.rb +1 -1
  249. data/spec/factories/cats/core/transport_bids.rb +1 -1
  250. data/spec/factories/cats/core/transport_contracts.rb +1 -1
  251. data/spec/factories/cats/core/transport_offers.rb +1 -1
  252. data/spec/factories/cats/core/transport_order_items.rb +1 -1
  253. data/spec/factories/cats/core/transport_orders.rb +1 -1
  254. data/spec/factories/cats/core/transport_plan_items.rb +1 -1
  255. data/spec/factories/cats/core/transport_plans.rb +1 -1
  256. data/spec/factories/cats/core/transport_requisition_details.rb +1 -1
  257. data/spec/factories/cats/core/transport_requisition_items.rb +1 -1
  258. data/spec/factories/cats/core/transport_requisitions.rb +1 -1
  259. data/spec/factories/cats/core/transporters.rb +1 -1
  260. data/spec/factories/cats/core/unit_conversions.rb +1 -1
  261. data/spec/factories/cats/core/unit_of_measures.rb +1 -1
  262. data/spec/factories/cats/core/users.rb +2 -2
  263. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 289a8b8aee41d9ad997ac46f363357ebb9961d983aaac22cd234133fb40a4e7e
4
- data.tar.gz: c2f3f4c71adbf4d2ffd07fd427d25afda5814459ca6217085882f5b2056049b1
3
+ metadata.gz: 8600827ecd1928a38a51faaac12c7fa5b99aabbe60f9d8f8bca25bd6ebb5ff12
4
+ data.tar.gz: 49b53ed37b83474a1fe315625edae660dce4307100f2a431d4b480e74a10cfb1
5
5
  SHA512:
6
- metadata.gz: a48354b502b466fefb8b346eb4cad0453630dac9803afd10737b33e475b7d532c213f8425a29e91658c8b2aacf4a46bb2568eec41d67ff0e4586d10700dfdfac
7
- data.tar.gz: f7b6788c688d1f6e95a1c182a083a24f6738db33d40ec11dfdc1899c3fe2c8b30b1f413ae489faeb61846974c3f2b5ffe4c74050ca52af20dbb68a1925d3ac18
6
+ metadata.gz: f56b80a25dbb39a4483888e722f884d46776f1c15a00d0fbd7596fcd0aab462c1a35a5d3adcfa4d4f599310f7b3d5b85079bb2794583f464286331b61b624003
7
+ data.tar.gz: 4074542f2decf95e6becf28b2cd83c438d1f141638d13ae1b33b523d1b650aa00dc8e50192ae8c4bcf4b985a95e3bc8bcd7c78dece4921363309d94549eb05cc
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require 'bundler/setup'
1
+ require "bundler/setup"
2
2
 
3
- APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
4
- load 'rails/tasks/engine.rake'
3
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
5
 
6
- load 'rails/tasks/statistics.rake'
6
+ load "rails/tasks/statistics.rake"
7
7
 
8
- require 'bundler/gem_tasks'
9
- require 'rspec/core/rake_task'
10
- RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
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: { error: 'User has no roles.' }, status: :unprocessable_entity
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: { token: jwt, user: payload }
22
+ render json: {token: jwt, user: payload}
23
23
  else
24
- render json: { error: 'Invalid password.' }, status: 400
24
+ render json: {error: "Invalid password."}, status: 400
25
25
  end
26
26
  else
27
- render json: { error: 'User does not exist.' }, status: 400
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['id'])
9
+ user = User.find(auth["id"])
10
10
  @current_user ||= user
11
11
  end
12
12
 
13
13
  def authenticate
14
- render json: { error: 'Unauthorized' }, status: 401 if current_user.nil?
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['HTTP_AUTHORIZATION'].nil?
33
+ return nil if request.env["HTTP_AUTHORIZATION"].nil?
34
34
 
35
- request.env['HTTP_AUTHORIZATION'].scan(/Bearer (.*)$/).flatten.last
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({ project: { source: :commodity_category } }, :unit_of_measure, :package_unit)
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: { success: result, data: serialize(commodity) }
16
- rescue StandardError => e
17
- render json: { success: false, error: e.message }
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: { success: true, data: serialize(query.result) }
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
- :source_type, :quantity, :best_use_before, :volume_per_metric_ton,
30
- :arrival_status, :shipping_reference, :package_unit_id)
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: { success: true, data: data }
14
+ render json: {success: true, data: data}
15
15
  end
16
16
 
17
17
  def root
18
18
  data = CommodityCategory.roots
19
- render json: { success: true, data: serialize(data) }
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: { success: true, data: serialize(parent.children) }
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('payload').permit(:code, :name, :description, :parent_id)
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(dispatch_id: params[:id])
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: { success: true, data: serialize(authorization) }, status: :created
18
+ render json: {success: true, data: serialize(authorization)}, status: :created
17
19
  else
18
- render json: { success: false, error: authorization.errors.full_messages[0] }, status: :unprocessable_entity
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: { success: true, data: serialize(authorization) }
26
- rescue StandardError => e
27
- render json: { success: false, error: e.message }
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
- .includes(:dispatch, :store, :authorized_by, :unit)
35
- .where(store: stores, dispatch: { dispatch_status: Dispatch::APPROVED })
36
- render json: { success: true, data: serialize(authorizations) }
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
- { commodity: { project: { source: :commodity_category } } },
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
- { commodity: { project: { source: :commodity_category } } },
22
+ {commodity: {project: {source: :commodity_category}}},
23
23
  :unit,
24
24
  :dispatch_plan
25
25
  ).ransack(params[:q])
26
- render json: { success: true, data: serialize(query.result) }
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
- :unit_id, :commodity_status, :status, :commodity_id)
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: { success: true, data: serialize(plans) }
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: { success: true, data: serialize(query.result) }
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: { success: true, data: serialize(plan) }, status: :created
26
- rescue StandardError => e
27
- render json: { success: false, error: e.message }, status: :unprocessable_entity
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: { success: true, data: serialize(items) }
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: { success: true, data: serialize(plan) }
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: { success: true, data: serialize(plan) }
47
- rescue StandardError => e
48
- render json: { success: false, error: e.message }
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: { code: 'SUP-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: { success: true, data: serialize(transaction) }, status: :created
26
+ render json: {success: true, data: serialize(transaction)}, status: :created
27
27
  else
28
- render json: { success: false, error: transaction.errors.full_messages[0] }, status: :unprocessable_entity
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: { success: true, data: serialize(query.result) }
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
- :reference_no)
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
- { dispatch_plan_item: :destination },
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: { success: true, data: serialize(dispatch) }
33
- rescue StandardError => e
34
- render json: { success: false, error: e.message }
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: { success: true, data: serialize(dispatch) }
40
- rescue StandardError => e
41
- render json: { success: false, error: e.message }
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: { success: true, data: serialize(dispatch) }
47
- rescue StandardError => e
48
- render json: { success: false, error: e.message }
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: { success: true, data: serialize(dispatch) }
55
- rescue StandardError => e
56
- render json: { success: false, error: e.message }
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
- { dispatch_plan_item: :destination },
61
+ {dispatch_plan_item: :destination},
62
62
  :transporter,
63
63
  :prepared_by,
64
64
  :unit
65
65
  ).ransack(params[:q])
66
- render json: { success: true, data: serialize(query.result) }
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: { success: true, data: serialize(data) }
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: { success: true, data: serialize(data) }
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
- :driver_name, :driver_phone, :remark)
87
+ :driver_name, :driver_phone, :remark)
88
88
  end
89
89
 
90
90
  def start_with_pin_params
@@ -13,7 +13,7 @@ module Cats
13
13
 
14
14
  def model_params
15
15
  params.require(:payload).permit(:reference_no, :description, :lender, :agreement_date, :repayment_date,
16
- :quantity, :unit_id, :commodity_category_id)
16
+ :quantity, :unit_id, :commodity_category_id)
17
17
  end
18
18
  end
19
19
  end
@@ -11,25 +11,25 @@ module Cats
11
11
 
12
12
  def children
13
13
  parent = Location.find(params[:id])
14
- render json: { success: true, data: serialize(parent.children) }
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: { success: true, data: serialize(query.result) }
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: { success: true, data: serialize(woredas) }
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: { success: true, data: serialize(fdp) }
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: { success: true, data: data }
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: { success: true, data: data }
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: { success: true, data: data }
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: { success: true, data: data }
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: { success: true, data: @notification.message }
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: { success: true, data: @notification.message }
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: { success: true, data: serialize(purchase_orders) }
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
- :commodity_category_id, :quantity, :purchase_type, :unit_id, :price,
20
- :currency_id, :description)
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: { success: true, data: serialize(authorization) }, status: :created
18
+ render json: {success: true, data: serialize(authorization)}, status: :created
19
19
  else
20
- render json: { success: false, error: authorization.errors.full_messages[0] }, status: :unprocessable_entity
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: { success: true, data: serialize(authorization) }
28
- rescue StandardError => e
29
- render json: { success: false, error: e.message }
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(params[:id], driver_confirm_params[:pin])
35
- render json: { success: true, data: serialize(authorization) }
36
- rescue StandardError => e
37
- render json: { success: false, error: e.message }
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: { success: true, data: serialize(authorization) }
45
- rescue StandardError => e
46
- render json: { success: false, error: e.message }
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
- .where(store: stores, status: status)
55
- render json: { success: true, data: serialize(authorizations) }
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
- :authorized_by_id)
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, { receipt_authorization: :dispatch }, :unit)
9
- .where(receipt_authorization_id: params[:id])
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: { success: true, data: serialize(query.result) }
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
- :transaction_date, :quantity, :unit_id)
22
+ :transaction_date, :quantity, :unit_id)
23
23
  end
24
24
  end
25
25
  end
@@ -13,7 +13,7 @@ module Cats
13
13
 
14
14
  def model_params
15
15
  params.require(:payload).permit(:receipt_authorization_id, :commodity_status, :commodity_grade, :quantity,
16
- :unit_id, :remark, :reference_no)
16
+ :unit_id, :remark, :reference_no)
17
17
  end
18
18
  end
19
19
  end