cats_core 1.5.19 → 1.5.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/cats/core/commodities_controller.rb +3 -3
  3. data/app/controllers/cats/core/dispatch_authorizations_controller.rb +4 -4
  4. data/app/controllers/cats/core/dispatch_plan_items_controller.rb +1 -1
  5. data/app/controllers/cats/core/dispatch_plans_controller.rb +2 -2
  6. data/app/controllers/cats/core/dispatch_transactions_controller.rb +1 -1
  7. data/app/controllers/cats/core/dispatches_controller.rb +5 -5
  8. data/app/controllers/cats/core/loans_controller.rb +1 -1
  9. data/app/controllers/cats/core/purchase_orders_controller.rb +2 -2
  10. data/app/controllers/cats/core/receipt_authorizations_controller.rb +5 -5
  11. data/app/controllers/cats/core/receipt_transactions_controller.rb +2 -2
  12. data/app/controllers/cats/core/receipts_controller.rb +1 -1
  13. data/app/controllers/cats/core/roles_controller.rb +1 -1
  14. data/app/controllers/cats/core/round_beneficiaries_controller.rb +5 -5
  15. data/app/controllers/cats/core/round_plans_controller.rb +3 -3
  16. data/app/controllers/cats/core/stack_transactions_controller.rb +1 -1
  17. data/app/controllers/cats/core/stacks_controller.rb +2 -2
  18. data/app/controllers/cats/core/stores_controller.rb +1 -1
  19. data/app/controllers/cats/core/swaps_controller.rb +2 -2
  20. data/app/controllers/cats/core/users_controller.rb +1 -1
  21. data/app/controllers/concerns/cats/core/common.rb +15 -16
  22. data/app/models/cats/core/authorization.rb +1 -1
  23. data/app/models/cats/core/beneficiary_plan_item.rb +1 -1
  24. data/app/models/cats/core/commodity.rb +16 -12
  25. data/app/models/cats/core/commodity_substitution.rb +2 -2
  26. data/app/models/cats/core/dispatch.rb +29 -16
  27. data/app/models/cats/core/dispatch_authorization.rb +7 -3
  28. data/app/models/cats/core/dispatch_plan.rb +14 -6
  29. data/app/models/cats/core/dispatch_plan_item.rb +20 -10
  30. data/app/models/cats/core/dispatch_transaction.rb +15 -8
  31. data/app/models/cats/core/location.rb +2 -2
  32. data/app/models/cats/core/receipt_authorization.rb +18 -2
  33. data/app/models/cats/core/receipt_transaction.rb +17 -2
  34. data/app/models/cats/core/round_beneficiary.rb +4 -4
  35. data/app/models/cats/core/round_plan.rb +20 -2
  36. data/app/models/cats/core/round_plan_item.rb +24 -2
  37. data/app/models/cats/core/route.rb +15 -2
  38. data/app/models/cats/core/stack.rb +40 -30
  39. data/app/models/cats/core/stacking_rule.rb +2 -2
  40. data/app/models/cats/core/store.rb +21 -21
  41. data/app/models/cats/core/transporter.rb +2 -2
  42. data/app/models/cats/core/unit_conversion.rb +1 -3
  43. data/app/serializers/cats/core/cash_donation_serializer.rb +1 -1
  44. data/app/serializers/cats/core/commodity_donation_serializer.rb +2 -2
  45. data/app/serializers/cats/core/commodity_serializer.rb +2 -2
  46. data/app/serializers/cats/core/dispatch_authorization_serializer.rb +2 -2
  47. data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +3 -3
  48. data/app/serializers/cats/core/dispatch_plan_serializer.rb +1 -1
  49. data/app/serializers/cats/core/dispatch_serializer.rb +2 -2
  50. data/app/serializers/cats/core/dispatch_transaction_serializer.rb +1 -1
  51. data/app/serializers/cats/core/loan_serializer.rb +1 -1
  52. data/app/serializers/cats/core/purchase_order_serializer.rb +2 -2
  53. data/app/serializers/cats/core/receipt_authorization_serializer.rb +2 -2
  54. data/app/serializers/cats/core/receipt_serializer.rb +1 -1
  55. data/app/serializers/cats/core/receipt_transaction_serializer.rb +2 -2
  56. data/app/serializers/cats/core/round_beneficiary_serializer.rb +1 -1
  57. data/app/serializers/cats/core/round_plan_serializer.rb +1 -1
  58. data/app/serializers/cats/core/stack_serializer.rb +1 -1
  59. data/app/serializers/cats/core/store_serializer.rb +1 -1
  60. data/app/serializers/cats/core/swap_serializer.rb +2 -2
  61. data/app/services/cats/core/authorization_service.rb +3 -9
  62. data/app/services/cats/core/beneficiary_service.rb +2 -2
  63. data/app/services/cats/core/dispatch_plan_service.rb +1 -1
  64. data/app/services/cats/core/dispatch_service.rb +18 -20
  65. data/app/services/cats/core/notification_service.rb +1 -1
  66. data/app/services/cats/core/round_plan_service.rb +4 -6
  67. data/app/services/cats/core/space_service.rb +6 -6
  68. data/app/services/cats/core/stack_service.rb +8 -8
  69. data/app/services/cats/core/user_service.rb +1 -1
  70. data/db/migrate/20210715114910_create_cats_core_users.rb +3 -3
  71. data/db/migrate/20210715120018_create_cats_core_roles.rb +11 -11
  72. data/db/migrate/20210715121244_create_cats_core_menus.rb +3 -3
  73. data/db/migrate/20210715122141_create_cats_core_menu_items.rb +3 -3
  74. data/db/migrate/20210715122423_create_cats_core_role_menus.rb +12 -12
  75. data/db/migrate/20210717031810_create_cats_core_plans.rb +3 -3
  76. data/db/migrate/20210717032024_create_cats_core_plan_items.rb +19 -19
  77. data/db/migrate/20210717032260_create_cats_core_beneficiary_categories.rb +3 -3
  78. data/db/migrate/20210717032270_create_cats_core_rations.rb +9 -9
  79. data/db/migrate/20210717032290_create_cats_core_beneficiary_plan_items.rb +7 -7
  80. data/db/migrate/20210717032295_create_cats_core_plan_item_details.rb +7 -7
  81. data/db/migrate/20210717032330_create_cats_core_commodity_donations.rb +12 -12
  82. data/db/migrate/20210717032408_create_cats_core_cash_donations.rb +6 -6
  83. data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +12 -12
  84. data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +12 -12
  85. data/db/migrate/20210717032927_create_cats_core_projects.rb +3 -3
  86. data/db/migrate/20210717033223_create_cats_core_commodities.rb +9 -9
  87. data/db/migrate/20210717140855_create_cats_core_stores.rb +3 -3
  88. data/db/migrate/20210717171101_create_cats_core_stacks.rb +9 -9
  89. data/db/migrate/20210718040129_create_cats_core_routes.rb +9 -9
  90. data/db/migrate/20210718042755_create_cats_core_rhn_requests.rb +6 -6
  91. data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +6 -6
  92. data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +15 -15
  93. data/db/migrate/20210718045516_create_cats_core_dispatches.rb +12 -12
  94. data/db/migrate/20210718055414_create_cats_core_dispatch_authorizations.rb +12 -12
  95. data/db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb +10 -10
  96. data/db/migrate/20210727074646_create_cats_core_receipt_authorizations.rb +12 -12
  97. data/db/migrate/20210727105834_create_cats_core_receipts.rb +6 -6
  98. data/db/migrate/20210728041505_create_cats_core_lost_commodities.rb +6 -6
  99. data/db/migrate/20210814160628_create_cats_core_receipt_transactions.rb +9 -9
  100. data/db/migrate/20210814175406_create_cats_core_stack_transactions.rb +9 -9
  101. data/db/migrate/20211215114737_create_cats_core_transport_plans.rb +3 -3
  102. data/db/migrate/20211215114835_create_cats_core_transport_plan_items.rb +9 -9
  103. data/db/migrate/20211215121151_create_cats_core_transport_bids.rb +3 -3
  104. data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +9 -9
  105. data/db/migrate/20211229160125_create_cats_core_transport_offers.rb +7 -7
  106. data/db/migrate/20211229160126_create_cats_core_offer_items.rb +6 -6
  107. data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +6 -6
  108. data/db/migrate/20211229160128_create_cats_core_contract_items.rb +9 -9
  109. data/db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb +10 -10
  110. data/db/migrate/20220103152802_create_cats_core_tenderers.rb +6 -6
  111. data/db/migrate/20220107121752_create_cats_core_round_plans.rb +6 -6
  112. data/db/migrate/20220107122280_create_cats_core_round_rations.rb +12 -12
  113. data/db/migrate/20220107125025_create_cats_core_round_plan_items.rb +18 -18
  114. data/db/migrate/20220107126025_create_cats_core_beneficiary_round_plan_items.rb +7 -7
  115. data/db/migrate/20220107132433_create_cats_core_round_plan_item_details.rb +9 -9
  116. data/db/migrate/20220209083928_create_cats_core_hub_authorizations.rb +12 -12
  117. data/db/migrate/20220416143416_create_cats_core_unit_conversions.rb +7 -7
  118. data/db/migrate/20220417105839_create_cats_core_transport_requisitions.rb +12 -12
  119. data/db/migrate/20220417123835_create_cats_core_transport_requisition_items.rb +9 -9
  120. data/db/migrate/20220417151821_create_cats_core_transport_requisition_details.rb +6 -6
  121. data/db/migrate/20220506082329_create_cats_core_transport_orders.rb +9 -9
  122. data/db/migrate/20220506083042_create_cats_core_transport_order_items.rb +12 -12
  123. data/db/migrate/20220511082354_create_cats_core_beneficiaries.rb +6 -6
  124. data/db/migrate/20220626063501_create_cats_core_loans.rb +6 -6
  125. data/db/migrate/20220626063757_create_cats_core_swaps.rb +12 -12
  126. data/db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb +12 -12
  127. data/db/migrate/20220923190857_create_cats_core_application_settings.rb +3 -3
  128. data/lib/cats/core/engine.rb +1 -3
  129. data/lib/cats/core/version.rb +1 -1
  130. data/spec/factories/cats/core/dispatch_authorizations.rb +1 -1
  131. data/spec/factories/cats/core/dispatch_plan_items.rb +1 -1
  132. data/spec/factories/cats/core/dispatches.rb +4 -4
  133. data/spec/factories/cats/core/round_plan_item_details.rb +1 -1
  134. metadata +41 -13
@@ -2,8 +2,8 @@ module Cats
2
2
  module Core
3
3
  class SwapSerializer < ActiveModel::Serializer
4
4
  attributes :id, :reference_no, :swapper, :agreement_date, :issued_commodity_id, :issued_commodity_name,
5
- :issued_quantity, :received_commodity_id, :received_commodity_name, :received_quantity,
6
- :issued_unit_id, :issued_unit_abbreviation, :received_unit_id, :received_unit_abbreviation
5
+ :issued_quantity, :received_commodity_id, :received_commodity_name, :received_quantity,
6
+ :issued_unit_id, :issued_unit_abbreviation, :received_unit_id, :received_unit_abbreviation
7
7
  end
8
8
  end
9
9
  end
@@ -3,9 +3,7 @@ module Cats
3
3
  class AuthorizationService
4
4
  def driver_confirm(authorization_id, pin, receipt_number)
5
5
  authorization = ReceiptAuthorization.find(authorization_id)
6
- if authorization.status == Authorization::AUTHORIZED
7
- raise(StandardError, "Authorization not confirmed by storekeeper.")
8
- end
6
+ raise(StandardError, "Authorization not confirmed by storekeeper.") if authorization.status == Authorization::AUTHORIZED
9
7
 
10
8
  raise(StandardError, "No pin has been generated for receipt.") if authorization.auth_details.nil?
11
9
 
@@ -65,14 +63,10 @@ module Cats
65
63
 
66
64
  def stack(authorization_id)
67
65
  authorization = ReceiptAuthorization.find(authorization_id)
68
- unless authorization.dispatch.dispatch_status == Dispatch::RECEIVED
69
- raise(StandardError, "Dispatch is not received.")
70
- end
66
+ raise(StandardError, "Dispatch is not received.") unless authorization.dispatch.dispatch_status == Dispatch::RECEIVED
71
67
 
72
68
  total = authorization.transactions.sum(:quantity)
73
- if total != authorization.received_quantity
74
- raise(StandardError, "Received quantity is not the same as quantity to be stacked.")
75
- end
69
+ raise(StandardError, "Received quantity is not the same as quantity to be stacked.") if total != authorization.received_quantity
76
70
 
77
71
  authorization.transactions.each(&:commit)
78
72
 
@@ -57,7 +57,7 @@ module Cats
57
57
  end
58
58
 
59
59
  beneficiaries = RoundBeneficiary.joins(:round_plan_item)
60
- .where(round_plan_item: {round_plan_id: plan_id})
60
+ .where(round_plan_item: {round_plan_id: plan_id})
61
61
  to_delete = RoundBeneficiary.where(id: ids)
62
62
  diff = to_delete - beneficiaries
63
63
  raise(StandardError, "Round plan beneficiaries should be from the same plan.") if diff.count.positive?
@@ -76,7 +76,7 @@ module Cats
76
76
  end
77
77
 
78
78
  beneficiaries = RoundBeneficiary.joins(:round_plan_item)
79
- .where(round_plan_item: {round_plan_id: plan_id})
79
+ .where(round_plan_item: {round_plan_id: plan_id})
80
80
  to_confirm = RoundBeneficiary.where(id: ids)
81
81
  diff = to_confirm - beneficiaries
82
82
  raise(StandardError, "Round plan beneficiaries should be from the same plan.") if diff.count.positive?
@@ -50,7 +50,7 @@ module Cats
50
50
  recipients = users.map do |user|
51
51
  details = user.details
52
52
  if (details.key?("warehouse") && details["warehouse"] == location_id) ||
53
- (details.key?("hub") && details["hub"] == location_id)
53
+ (details.key?("hub") && details["hub"] == location_id)
54
54
  user
55
55
  end
56
56
  end.compact
@@ -4,33 +4,31 @@ module Cats
4
4
  def search(user, status, authorized: false)
5
5
  details = user.details
6
6
 
7
- unless details["stores"] || details["warehouse"] || details["hub"]
8
- raise(StandardError, "User does not have associated location.")
9
- end
7
+ raise(StandardError, "User does not have associated location.") unless details["stores"] || details["warehouse"] || details["hub"]
10
8
 
11
9
  # Get user's hub
12
10
  hub = if details["stores"]
13
- Store.find(details["stores"][0]).warehouse.parent
14
- elsif details["warehouse"]
15
- Location.find(details["warehouse"]).parent
16
- else
17
- Location.find(details["hub"])
18
- end
11
+ Store.find(details["stores"][0]).warehouse.parent
12
+ elsif details["warehouse"]
13
+ Location.find(details["warehouse"]).parent
14
+ else
15
+ Location.find(details["hub"])
16
+ end
19
17
 
20
18
  if authorized
21
19
  return Dispatch.joins(:dispatch_plan_item)
22
- .includes({dispatch_plan_item: :destination}, :transporter, :prepared_by, :unit)
23
- .where(
24
- dispatch_plan_item: {destination: hub, status: DispatchPlanItem::AUTHORIZED},
25
- dispatch_status: status
26
- )
20
+ .includes({dispatch_plan_item: :destination}, :transporter, :prepared_by, :unit)
21
+ .where(
22
+ dispatch_plan_item: {destination: hub, status: DispatchPlanItem::AUTHORIZED},
23
+ dispatch_status: status
24
+ )
27
25
  end
28
26
  Dispatch.joins(:dispatch_plan_item)
29
- .includes({dispatch_plan_item: :destination}, :transporter, :prepared_by, :unit)
30
- .where(
31
- dispatch_plan_item: {destination: hub},
32
- dispatch_status: status
33
- )
27
+ .includes({dispatch_plan_item: :destination}, :transporter, :prepared_by, :unit)
28
+ .where(
29
+ dispatch_plan_item: {destination: hub},
30
+ dispatch_status: status
31
+ )
34
32
  end
35
33
 
36
34
  def start(dispatch)
@@ -77,7 +75,7 @@ module Cats
77
75
  details = user.details
78
76
 
79
77
  if (details.key?("warehouse") && hub.child_ids.include?(details["warehouse"])) ||
80
- (details.key?("hub") && details["hub"] == location_id)
78
+ (details.key?("hub") && details["hub"] == location_id)
81
79
  user
82
80
  end
83
81
  end.compact
@@ -34,7 +34,7 @@ module Cats
34
34
  roles = rule[:recipients]
35
35
 
36
36
  users = Cats::Core::User.joins(:application_module)
37
- .where(application_module: {prefix: app_code}).with_all_roles(*roles)
37
+ .where(application_module: {prefix: app_code}).with_all_roles(*roles)
38
38
  notifier.deliver(users)
39
39
  end
40
40
  end
@@ -18,7 +18,7 @@ module Cats
18
18
  round_rations = rations.select { |r| r.beneficiary_category_id == plan_item.beneficiary_category_id }
19
19
  round_rations.each do |ration|
20
20
  quantity = (no_of_days / ration.no_of_days * ration.quantity) * plan_item.beneficiaries *
21
- round_plan.rounds.count
21
+ round_plan.rounds.count
22
22
  quantity = quantity.truncate(2)
23
23
  unit = ration.unit
24
24
  if ration.unit.abbreviation.downcase != "pc"
@@ -120,18 +120,16 @@ module Cats
120
120
  end
121
121
 
122
122
  plans = Cats::Core::RoundPlan.includes(:beneficiary_round_plan_items)
123
- .where(beneficiary_round_plan_items: {id: ids})
123
+ .where(beneficiary_round_plan_items: {id: ids})
124
124
  raise(StandardError, "Round plan items should be from the same plan.") if plans.count > 1
125
125
 
126
- unless plans.count.positive? && plan.id == plans[0].id
127
- raise(StandardError, "Round plan items are not from the given round plan.")
128
- end
126
+ raise(StandardError, "Round plan items are not from the given round plan.") unless plans.count.positive? && plan.id == plans[0].id
129
127
 
130
128
  to_delete = Cats::Core::BeneficiaryRoundPlanItem.where(id: ids)
131
129
  keys = to_delete.map(&:round_plan_item_id).uniq
132
130
 
133
131
  item_counts = Cats::Core::BeneficiaryRoundPlanItem.where(round_plan_item_id: keys)
134
- .group(:round_plan_item_id).count
132
+ .group(:round_plan_item_id).count
135
133
 
136
134
  delete_hash = {}
137
135
  keys.each { |k| delete_hash[k] = [] }
@@ -12,12 +12,12 @@ module Cats
12
12
  warehouses = hub.children
13
13
  warehouse_ids = warehouses.map(&:id)
14
14
  stores = Cats::Core::Store.joins(:warehouse)
15
- .where(
16
- cats_core_locations: {
17
- location_type: Cats::Core::Location::WAREHOUSE,
18
- id: warehouse_ids
19
- }
20
- ).group_by(&:warehouse_id)
15
+ .where(
16
+ cats_core_locations: {
17
+ location_type: Cats::Core::Location::WAREHOUSE,
18
+ id: warehouse_ids
19
+ }
20
+ ).group_by(&:warehouse_id)
21
21
  wh_details = []
22
22
  stores.each do |key, value|
23
23
  total_space = value.inject(0) { |sum, val| sum + val.available_space }
@@ -8,17 +8,17 @@ module Cats
8
8
  raise(StandardError, "User does not have associated location.") unless key_available
9
9
 
10
10
  hub = if details["hub"]
11
- Location.find(details["hub"])
12
- elsif details["warehouse"]
13
- Location.find(details["warehouse"]).parent
14
- else
15
- Store.find(details["stores"][0]).warehouse.parent
16
- end
11
+ Location.find(details["hub"])
12
+ elsif details["warehouse"]
13
+ Location.find(details["warehouse"]).parent
14
+ else
15
+ Store.find(details["stores"][0]).warehouse.parent
16
+ end
17
17
 
18
18
  allocation_items =
19
19
  DispatchPlanItem
20
- .joins(:dispatch_plan)
21
- .where(destination: hub, dispatch_plan: {status: DispatchPlan::APPROVED})
20
+ .joins(:dispatch_plan)
21
+ .where(destination: hub, dispatch_plan: {status: DispatchPlan::APPROVED})
22
22
 
23
23
  allocation_items.map do |item|
24
24
  {
@@ -4,7 +4,7 @@ module Cats
4
4
  def change_password(email, old_password, new_password, password_confirmation)
5
5
  raise(StandardError, "Password and confirmation do not match.") unless new_password == password_confirmation
6
6
 
7
- user = User.find_by(email:)
7
+ user = User.find_by(email: email)
8
8
  raise(StandardError, "User with email '#{email}' could not be found.") unless user
9
9
 
10
10
  raise(StandardError, "Old password for user '#{email}' is not correct.") unless user.authenticate(old_password)
@@ -9,9 +9,9 @@ class CreateCatsCoreUsers < ActiveRecord::Migration[6.1]
9
9
  t.jsonb :details, null: false, default: {}
10
10
  t.string :phone_number
11
11
  t.references :application_module,
12
- null: false,
13
- index: {name: "am_on_users_indx"},
14
- foreign_key: {to_table: :cats_core_application_modules}
12
+ null: false,
13
+ index: {name: "am_on_users_indx"},
14
+ foreign_key: {to_table: :cats_core_application_modules}
15
15
 
16
16
  t.timestamps
17
17
  end
@@ -4,25 +4,25 @@ class CreateCatsCoreRoles < ActiveRecord::Migration[6.1]
4
4
  t.string :name
5
5
  t.references :resource, polymorphic: true
6
6
  t.references :application_module,
7
- null: false,
8
- index: {name: "am_on_roles_indx"},
9
- foreign_key: {to_table: :cats_core_application_modules}
7
+ null: false,
8
+ index: {name: "am_on_roles_indx"},
9
+ foreign_key: {to_table: :cats_core_application_modules}
10
10
 
11
11
  t.timestamps
12
12
  end
13
13
 
14
14
  create_table(:cats_core_users_cats_core_roles, id: false) do |t|
15
15
  t.references :user,
16
- null: false,
17
- index: {name: "user_on_ur_indx"},
18
- foreign_key: {to_table: :cats_core_users}
16
+ null: false,
17
+ index: {name: "user_on_ur_indx"},
18
+ foreign_key: {to_table: :cats_core_users}
19
19
  t.references :role,
20
- null: false,
21
- index: {name: "role_on_ur_indx"},
22
- foreign_key: {to_table: :cats_core_roles}
20
+ null: false,
21
+ index: {name: "role_on_ur_indx"},
22
+ foreign_key: {to_table: :cats_core_roles}
23
23
  end
24
24
 
25
- add_index(:cats_core_roles, [:name, :resource_type, :resource_id])
26
- add_index(:cats_core_users_cats_core_roles, [:user_id, :role_id], unique: true)
25
+ add_index(:cats_core_roles, %i[name resource_type resource_id])
26
+ add_index(:cats_core_users_cats_core_roles, %i[user_id role_id], unique: true)
27
27
  end
28
28
  end
@@ -4,9 +4,9 @@ class CreateCatsCoreMenus < ActiveRecord::Migration[6.1]
4
4
  t.string :label, null: false
5
5
  t.string :icon
6
6
  t.references :application_module,
7
- null: false,
8
- index: {name: "am_on_menus_indx"},
9
- foreign_key: {to_table: :cats_core_application_modules}
7
+ null: false,
8
+ index: {name: "am_on_menus_indx"},
9
+ foreign_key: {to_table: :cats_core_application_modules}
10
10
 
11
11
  t.timestamps
12
12
  end
@@ -5,9 +5,9 @@ class CreateCatsCoreMenuItems < ActiveRecord::Migration[6.1]
5
5
  t.string :icon
6
6
  t.string :route, null: false
7
7
  t.references :menu,
8
- null: false,
9
- index: {name: "menu_on_mi_indx"},
10
- foreign_key: {to_table: :cats_core_menus}
8
+ null: false,
9
+ index: {name: "menu_on_mi_indx"},
10
+ foreign_key: {to_table: :cats_core_menus}
11
11
 
12
12
  t.timestamps
13
13
  end
@@ -2,13 +2,13 @@ class CreateCatsCoreRoleMenus < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_role_menus do |t|
4
4
  t.references :role,
5
- null: false,
6
- index: {name: "role_on_rm_indx"},
7
- foreign_key: {to_table: :cats_core_roles}
5
+ null: false,
6
+ index: {name: "role_on_rm_indx"},
7
+ foreign_key: {to_table: :cats_core_roles}
8
8
  t.references :menu,
9
- null: false,
10
- index: {name: "menu_on_rm_indx"},
11
- foreign_key: {to_table: :cats_core_menus}
9
+ null: false,
10
+ index: {name: "menu_on_rm_indx"},
11
+ foreign_key: {to_table: :cats_core_menus}
12
12
  t.string :description
13
13
 
14
14
  t.timestamps
@@ -16,13 +16,13 @@ class CreateCatsCoreRoleMenus < ActiveRecord::Migration[6.1]
16
16
 
17
17
  create_table(:cats_core_role_menus_menu_items, id: false) do |t|
18
18
  t.references :role_menu,
19
- null: false,
20
- index: {name: "rm_on_ummi_indx"},
21
- foreign_key: {to_table: :cats_core_role_menus}
19
+ null: false,
20
+ index: {name: "rm_on_ummi_indx"},
21
+ foreign_key: {to_table: :cats_core_role_menus}
22
22
  t.references :menu_item,
23
- null: false,
24
- index: {name: "mi_on_ummi_indx"},
25
- foreign_key: {to_table: :cats_core_menu_items}
23
+ null: false,
24
+ index: {name: "mi_on_ummi_indx"},
25
+ foreign_key: {to_table: :cats_core_menu_items}
26
26
  end
27
27
  end
28
28
  end
@@ -10,9 +10,9 @@ class CreateCatsCorePlans < ActiveRecord::Migration[6.1]
10
10
  t.integer :rounds, null: false
11
11
 
12
12
  t.references :program,
13
- null: false,
14
- index: {name: "program_on_plan_indx"},
15
- foreign_key: {to_table: :cats_core_programs}
13
+ null: false,
14
+ index: {name: "program_on_plan_indx"},
15
+ foreign_key: {to_table: :cats_core_programs}
16
16
 
17
17
  t.timestamps
18
18
  end
@@ -2,33 +2,33 @@ class CreateCatsCorePlanItems < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_plan_items do |t|
4
4
  t.references :plan,
5
- null: false,
6
- index: {name: "plan_on_plan_items_indx"},
7
- foreign_key: {to_table: :cats_core_plans}
5
+ null: false,
6
+ index: {name: "plan_on_plan_items_indx"},
7
+ foreign_key: {to_table: :cats_core_plans}
8
8
  t.references :region,
9
- null: false,
10
- index: {name: "region_on_plan_items_indx"},
11
- foreign_key: {to_table: :cats_core_locations}
9
+ null: false,
10
+ index: {name: "region_on_plan_items_indx"},
11
+ foreign_key: {to_table: :cats_core_locations}
12
12
  t.references :zone,
13
- null: false,
14
- index: {name: "zone_on_plan_items_indx"},
15
- foreign_key: {to_table: :cats_core_locations}
13
+ null: false,
14
+ index: {name: "zone_on_plan_items_indx"},
15
+ foreign_key: {to_table: :cats_core_locations}
16
16
  t.references :woreda,
17
- null: false,
18
- index: {name: "woreda_on_plan_items_idnx"},
19
- foreign_key: {to_table: :cats_core_locations}
17
+ null: false,
18
+ index: {name: "woreda_on_plan_items_idnx"},
19
+ foreign_key: {to_table: :cats_core_locations}
20
20
  t.references :fdp,
21
- null: false,
22
- index: {name: "fdp_on_plan_items_indx"},
23
- foreign_key: {to_table: :cats_core_locations}
21
+ null: false,
22
+ index: {name: "fdp_on_plan_items_indx"},
23
+ foreign_key: {to_table: :cats_core_locations}
24
24
  t.references :operator,
25
- null: false,
26
- index: {name: "operator_on_plan_items_indx"},
27
- foreign_key: {to_table: :cats_core_operators}
25
+ null: false,
26
+ index: {name: "operator_on_plan_items_indx"},
27
+ foreign_key: {to_table: :cats_core_operators}
28
28
 
29
29
  t.timestamps
30
30
  end
31
31
 
32
- add_index :cats_core_plan_items, [:plan_id, :fdp_id], unique: true
32
+ add_index :cats_core_plan_items, %i[plan_id fdp_id], unique: true
33
33
  end
34
34
  end
@@ -4,9 +4,9 @@ class CreateCatsCoreBeneficiaryCategories < ActiveRecord::Migration[7.0]
4
4
  t.string :code, unique: true
5
5
  t.string :name, null: false
6
6
  t.references :plan,
7
- null: false,
8
- index: {name: "plan_on_bc_indx"},
9
- foreign_key: {to_table: :cats_core_plans}
7
+ null: false,
8
+ index: {name: "plan_on_bc_indx"},
9
+ foreign_key: {to_table: :cats_core_plans}
10
10
 
11
11
  t.timestamps
12
12
  end
@@ -3,17 +3,17 @@ class CreateCatsCoreRations < ActiveRecord::Migration[6.1]
3
3
  create_table :cats_core_rations do |t|
4
4
  t.string :reference_no, unique: true
5
5
  t.references :beneficiary_category,
6
- null: false,
7
- index: {name: "bc_on_ration_indx"},
8
- foreign_key: {to_table: :cats_core_beneficiary_categories}
6
+ null: false,
7
+ index: {name: "bc_on_ration_indx"},
8
+ foreign_key: {to_table: :cats_core_beneficiary_categories}
9
9
  t.references :commodity_category,
10
- null: false,
11
- index: {name: "cc_on_ration_indx"},
12
- foreign_key: {to_table: :cats_core_commodity_categories}
10
+ null: false,
11
+ index: {name: "cc_on_ration_indx"},
12
+ foreign_key: {to_table: :cats_core_commodity_categories}
13
13
  t.references :unit_of_measure,
14
- null: false,
15
- index: {name: "uom_on_ration_indx"},
16
- foreign_key: {to_table: :cats_core_unit_of_measures}
14
+ null: false,
15
+ index: {name: "uom_on_ration_indx"},
16
+ foreign_key: {to_table: :cats_core_unit_of_measures}
17
17
  t.float :quantity, null: false
18
18
  t.integer :no_of_days, null: false
19
19
 
@@ -2,13 +2,13 @@ class CreateCatsCoreBeneficiaryPlanItems < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :cats_core_beneficiary_plan_items do |t|
4
4
  t.references :plan_item,
5
- null: false,
6
- index: {name: "pi_on_bpi_indx"},
7
- foreign_key: {to_table: :cats_core_plan_items}
5
+ null: false,
6
+ index: {name: "pi_on_bpi_indx"},
7
+ foreign_key: {to_table: :cats_core_plan_items}
8
8
  t.references :beneficiary_category,
9
- null: false,
10
- index: {name: "bc_on_bpi_indx"},
11
- foreign_key: {to_table: :cats_core_beneficiary_categories}
9
+ null: false,
10
+ index: {name: "bc_on_bpi_indx"},
11
+ foreign_key: {to_table: :cats_core_beneficiary_categories}
12
12
  t.integer :beneficiaries, null: false
13
13
 
14
14
  t.integer :rounds
@@ -18,7 +18,7 @@ class CreateCatsCoreBeneficiaryPlanItems < ActiveRecord::Migration[7.0]
18
18
  end
19
19
  add_index(
20
20
  :cats_core_beneficiary_plan_items,
21
- [:plan_item_id, :beneficiary_category_id],
21
+ %i[plan_item_id beneficiary_category_id],
22
22
  unique: true,
23
23
  name: "pii_on_bci_uniq_indx"
24
24
  )
@@ -2,17 +2,17 @@ class CreateCatsCorePlanItemDetails < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_plan_item_details do |t|
4
4
  t.references :beneficiary_plan_item,
5
- null: false,
6
- index: {name: "bpi_on_pid_indx"},
7
- foreign_key: {to_table: :cats_core_beneficiary_plan_items}
5
+ null: false,
6
+ index: {name: "bpi_on_pid_indx"},
7
+ foreign_key: {to_table: :cats_core_beneficiary_plan_items}
8
8
  t.references :ration,
9
- null: false,
10
- index: {name: "ration_on_pid_indx"},
11
- foreign_key: {to_table: :cats_core_rations}
9
+ null: false,
10
+ index: {name: "ration_on_pid_indx"},
11
+ foreign_key: {to_table: :cats_core_rations}
12
12
  t.float :quantity, null: false
13
13
 
14
14
  t.timestamps
15
15
  end
16
- add_index(:cats_core_plan_item_details, [:beneficiary_plan_item_id, :ration_id], unique: true, name: "bpii_ri_on_pid_indx")
16
+ add_index(:cats_core_plan_item_details, %i[beneficiary_plan_item_id ration_id], unique: true, name: "bpii_ri_on_pid_indx")
17
17
  end
18
18
  end
@@ -6,22 +6,22 @@ class CreateCatsCoreCommodityDonations < ActiveRecord::Migration[6.1]
6
6
  t.string :shipping_reference
7
7
  t.date :donated_on, null: false
8
8
  t.references :donor,
9
- null: false,
10
- index: {name: "donor_on_cd_indx"},
11
- foreign_key: {to_table: :cats_core_donors}
9
+ null: false,
10
+ index: {name: "donor_on_cd_indx"},
11
+ foreign_key: {to_table: :cats_core_donors}
12
12
  t.references :commodity_category,
13
- null: false,
14
- index: {name: "cc_on_cd_indx"},
15
- foreign_key: {to_table: :cats_core_commodity_categories}
13
+ null: false,
14
+ index: {name: "cc_on_cd_indx"},
15
+ foreign_key: {to_table: :cats_core_commodity_categories}
16
16
  t.references :plan,
17
- null: true,
18
- index: {name: "plan_on_cd_indx"},
19
- foreign_key: {to_table: :cats_core_plans}
17
+ null: true,
18
+ index: {name: "plan_on_cd_indx"},
19
+ foreign_key: {to_table: :cats_core_plans}
20
20
  t.float :quantity, null: false
21
21
  t.references :unit,
22
- null: false,
23
- index: {name: "unit_on_cd_indx"},
24
- foreign_key: {to_table: :cats_core_unit_of_measures}
22
+ null: false,
23
+ index: {name: "unit_on_cd_indx"},
24
+ foreign_key: {to_table: :cats_core_unit_of_measures}
25
25
 
26
26
  t.timestamps
27
27
  end
@@ -5,14 +5,14 @@ class CreateCatsCoreCashDonations < ActiveRecord::Migration[7.0]
5
5
  t.string :description
6
6
  t.date :donated_on, null: false
7
7
  t.references :donor,
8
- null: false,
9
- index: {name: "donor_on_cad_indx"},
10
- foreign_key: {to_table: :cats_core_donors}
8
+ null: false,
9
+ index: {name: "donor_on_cad_indx"},
10
+ foreign_key: {to_table: :cats_core_donors}
11
11
  t.float :amount, null: false
12
12
  t.references :currency,
13
- null: false,
14
- index: {name: "currency_on_cad_indx"},
15
- foreign_key: {to_table: :cats_core_currencies}
13
+ null: false,
14
+ index: {name: "currency_on_cad_indx"},
15
+ foreign_key: {to_table: :cats_core_currencies}
16
16
 
17
17
  t.timestamps
18
18
  end
@@ -11,23 +11,23 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
11
11
  t.string :bill_of_lading_no
12
12
  t.float :quantity, null: false
13
13
  t.references :commodity_category,
14
- null: false,
15
- index: {name: "gc_on_cc_indx"},
16
- foreign_key: {to_table: :cats_core_commodity_categories}
14
+ null: false,
15
+ index: {name: "gc_on_cc_indx"},
16
+ foreign_key: {to_table: :cats_core_commodity_categories}
17
17
  t.references :unit,
18
- null: false,
19
- index: {name: "unit_on_gc_indx"},
20
- foreign_key: {to_table: :cats_core_unit_of_measures}
18
+ null: false,
19
+ index: {name: "unit_on_gc_indx"},
20
+ foreign_key: {to_table: :cats_core_unit_of_measures}
21
21
  t.references :destination_warehouse,
22
- null: false,
23
- index: {name: "dw_on_gc_indx"},
24
- foreign_key: {to_table: :cats_core_locations}
22
+ null: false,
23
+ index: {name: "dw_on_gc_indx"},
24
+ foreign_key: {to_table: :cats_core_locations}
25
25
  t.float :estimated_price
26
26
  t.float :estimated_tax
27
27
  t.references :currency,
28
- null: false,
29
- index: {name: "currency_on_gc_indx"},
30
- foreign_key: {to_table: :cats_core_currencies}
28
+ null: false,
29
+ index: {name: "currency_on_gc_indx"},
30
+ foreign_key: {to_table: :cats_core_currencies}
31
31
  t.string :registration_no
32
32
  t.string :requested_by, null: false
33
33
  t.string :request_reference