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.
- 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
@@ -2,47 +2,47 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class Stack < ApplicationRecord
|
4
4
|
# Stack statuses
|
5
|
-
RESERVED =
|
6
|
-
ALLOCATED =
|
7
|
-
DESTROYED =
|
5
|
+
RESERVED = "Reserved".freeze
|
6
|
+
ALLOCATED = "Allocated".freeze
|
7
|
+
DESTROYED = "Destroyed".freeze
|
8
8
|
STACK_STATUSES = [RESERVED, ALLOCATED, DESTROYED].freeze
|
9
9
|
|
10
10
|
belongs_to :commodity
|
11
11
|
belongs_to :store
|
12
|
-
belongs_to :unit, class_name:
|
12
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
13
13
|
|
14
14
|
has_many :dispatch_transactions, foreign_key: :source_id
|
15
15
|
has_many :receipt_transactions, foreign_key: :destination_id
|
16
16
|
|
17
17
|
validates :code, :length, :width, :height, :start_x, :start_y, :commodity_status, :stack_status,
|
18
|
-
|
18
|
+
:quantity, presence: true
|
19
19
|
validates :code, uniqueness: true
|
20
|
-
validates :length, :width, :height, :start_x, :start_y, numericality: {
|
21
|
-
validates :quantity, numericality: {
|
22
|
-
validates :commodity_status, inclusion: {
|
23
|
-
validates :stack_status, inclusion: {
|
20
|
+
validates :length, :width, :height, :start_x, :start_y, numericality: {greater_than: 0}
|
21
|
+
validates :quantity, numericality: {greater_than_or_equal_to: 0}
|
22
|
+
validates :commodity_status, inclusion: {in: Cats::Core::Commodity::COMMODITY_STATUSES}
|
23
|
+
validates :stack_status, inclusion: {in: STACK_STATUSES}
|
24
24
|
validate :validate_coordinates, :validate_dimensions, :validate_distance_from_wall, :validate_overlap,
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
:validate_space_between_stack, :validate_max_height, :validate_max_length, :validate_max_width,
|
26
|
+
:validate_distance_from_ceiling,
|
27
|
+
unless: -> { store && (store.code == "SUP-STORE" || store.code.start_with?("FDP-ST")) }
|
28
28
|
|
29
29
|
delegate :batch_no, to: :commodity, prefix: true
|
30
30
|
delegate :abbreviation, to: :unit, prefix: true
|
31
31
|
|
32
|
-
after_save :update_store_space
|
32
|
+
after_save :update_store_space
|
33
33
|
|
34
34
|
def validate_coordinates
|
35
35
|
return unless store.present? && length.present? && width.present? && start_x.present? && start_y.present?
|
36
36
|
|
37
|
-
errors.add(:start_x,
|
38
|
-
errors.add(:start_y,
|
37
|
+
errors.add(:start_x, "cannot exceed length") if start_x.present? && start_x > store.length
|
38
|
+
errors.add(:start_y, "cannot exceed width") if start_y.present? && start_y > store.width
|
39
39
|
end
|
40
40
|
|
41
41
|
def validate_dimensions
|
42
42
|
return unless store.present? && length.present? && width.present? && start_x.present? && start_y.present?
|
43
43
|
|
44
|
-
errors.add(:length,
|
45
|
-
errors.add(:width,
|
44
|
+
errors.add(:length, "cannot exceed store length") if start_x + length > store.length
|
45
|
+
errors.add(:width, "cannot exceed store width") if start_y + width > store.width
|
46
46
|
end
|
47
47
|
|
48
48
|
def stacking_rules
|
@@ -66,9 +66,9 @@ module Cats
|
|
66
66
|
|
67
67
|
rule = stacking_rules
|
68
68
|
if start_x < rule.distance_from_wall || store.length - (start_x + length) < rule.distance_from_wall ||
|
69
|
-
|
69
|
+
store.width - (start_y + width) < rule.distance_from_wall || start_y < rule.distance_from_wall
|
70
70
|
errors.add(:base,
|
71
|
-
|
71
|
+
message: "The stack must be placed #{rule.distance_from_wall} meter away from a store wall")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -89,9 +89,9 @@ module Cats
|
|
89
89
|
rule = stacking_rules
|
90
90
|
new_stack = dup
|
91
91
|
new_stack.assign_attributes(start_x: start_x - rule.space_between_stack,
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
start_y: start_y - rule.space_between_stack,
|
93
|
+
length: length + (2 * rule.space_between_stack),
|
94
|
+
width: width + (2 * rule.space_between_stack))
|
95
95
|
stacks.each do |s|
|
96
96
|
errors.add(:base, message: "#{code} overlaps with #{s.code}") if overlaps?(new_stack, s)
|
97
97
|
end
|
@@ -100,19 +100,19 @@ module Cats
|
|
100
100
|
def validate_max_height
|
101
101
|
return unless height
|
102
102
|
|
103
|
-
errors.add(:height,
|
103
|
+
errors.add(:height, "exceeds stacking rule height.") if height > stacking_rules.maximum_height
|
104
104
|
end
|
105
105
|
|
106
106
|
def validate_max_length
|
107
107
|
return unless length
|
108
108
|
|
109
|
-
errors.add(:length,
|
109
|
+
errors.add(:length, "exceeds stacking rule length.") if length > stacking_rules.maximum_length
|
110
110
|
end
|
111
111
|
|
112
112
|
def validate_max_width
|
113
113
|
return unless width
|
114
114
|
|
115
|
-
errors.add(:width,
|
115
|
+
errors.add(:width, "exceeds stacking rule width.") if width > stacking_rules.maximum_width
|
116
116
|
end
|
117
117
|
|
118
118
|
def validate_distance_from_ceiling
|
@@ -120,7 +120,7 @@ module Cats
|
|
120
120
|
|
121
121
|
return unless store.height - height < stacking_rules.distance_from_ceiling
|
122
122
|
|
123
|
-
errors.add(:height,
|
123
|
+
errors.add(:height, "of stack is close to the ceiling.")
|
124
124
|
end
|
125
125
|
|
126
126
|
# A method that checks if an overlap exists b/n two stacks.
|
@@ -140,10 +140,10 @@ module Cats
|
|
140
140
|
return unless length_previously_changed? || width_previously_changed? || stack_status_previously_changed?
|
141
141
|
|
142
142
|
old_area = if length_previously_was.nil? && width_previously_was.nil?
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
0
|
144
|
+
else
|
145
|
+
length_previously_was * width_previously_was
|
146
|
+
end
|
147
147
|
|
148
148
|
store.available_space += old_area
|
149
149
|
store.available_space -= length * width unless stack_status == DESTROYED
|
@@ -154,7 +154,7 @@ module Cats
|
|
154
154
|
def self.search_commodity(batch_no)
|
155
155
|
commodity = Commodity.find_by(batch_no: batch_no)
|
156
156
|
stacks = Stack.joins(:commodity, store: :warehouse).where(
|
157
|
-
commodity: {
|
157
|
+
commodity: {batch_no: batch_no},
|
158
158
|
stack_status: Stack::ALLOCATED
|
159
159
|
)
|
160
160
|
stacks.map do |stack|
|
@@ -171,10 +171,28 @@ module Cats
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def destroy_stack
|
174
|
-
|
174
|
+
if stack_status == Cats::Core::Stack::RESERVED || quantity.zero?
|
175
|
+
self.stack_status = Cats::Core::Stack::DESTROYED
|
176
|
+
save!
|
177
|
+
else
|
178
|
+
raise(StandardError, "Stack has to be either RESERVED or with zero quantity to be destroyed.")
|
179
|
+
end
|
180
|
+
end
|
175
181
|
|
176
|
-
|
177
|
-
|
182
|
+
def self.ransackable_attributes(auth_object = nil)
|
183
|
+
[
|
184
|
+
"commodity_id",
|
185
|
+
"commodity_status",
|
186
|
+
"height",
|
187
|
+
"length",
|
188
|
+
"quantity",
|
189
|
+
"stack_status",
|
190
|
+
"start_x",
|
191
|
+
"start_y",
|
192
|
+
"store_id",
|
193
|
+
"unit_id",
|
194
|
+
"width"
|
195
|
+
]
|
178
196
|
end
|
179
197
|
end
|
180
198
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class StackTransaction < Transaction
|
4
|
-
belongs_to :source, class_name:
|
5
|
-
belongs_to :destination, class_name:
|
6
|
-
belongs_to :unit, class_name:
|
4
|
+
belongs_to :source, class_name: "Cats::Core::Stack"
|
5
|
+
belongs_to :destination, class_name: "Cats::Core::Stack"
|
6
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
7
7
|
|
8
8
|
def validate_quantity
|
9
9
|
return unless quantity.present? && source.present?
|
@@ -2,14 +2,14 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class StackingRule < ApplicationRecord
|
4
4
|
validates :distance_from_wall, :space_between_stack, :distance_from_ceiling, :maximum_height, :maximum_length,
|
5
|
-
|
5
|
+
:maximum_width, :distance_from_gangway, presence: true, numericality: {greater_than: 0}
|
6
6
|
validate :validate_only_a_record_exist
|
7
7
|
|
8
8
|
def validate_only_a_record_exist
|
9
9
|
return unless StackingRule.count > 1
|
10
10
|
|
11
11
|
errors.add(:base,
|
12
|
-
|
12
|
+
"There is already a stacking rule entry. A new rule can not be added")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Store < ApplicationRecord
|
4
|
-
belongs_to :warehouse, class_name:
|
4
|
+
belongs_to :warehouse, class_name: "Cats::Core::Location"
|
5
5
|
has_many :stacks
|
6
6
|
|
7
7
|
validates :code, :name, :length, :width, :height, presence: true
|
8
8
|
validates :code, uniqueness: true
|
9
|
-
validates :length, :width, :height, numericality: {
|
9
|
+
validates :length, :width, :height, numericality: {greater_than: 0}
|
10
10
|
validates :gangway_length, :gangway_width, :gangway_corner_dist, presence: true, if: :has_gangway?
|
11
11
|
validates :gangway_length,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
:gangway_width,
|
13
|
+
:gangway_corner_dist,
|
14
|
+
numericality: {greater_than: 0},
|
15
|
+
allow_nil: true
|
16
16
|
validate :validate_location
|
17
17
|
|
18
18
|
before_create :update_usable_space
|
@@ -20,7 +20,7 @@ module Cats
|
|
20
20
|
def validate_location
|
21
21
|
return if warehouse.nil?
|
22
22
|
|
23
|
-
errors.add(:warehouse,
|
23
|
+
errors.add(:warehouse, "must be a valid warehouse") unless warehouse.location_type == Location::WAREHOUSE
|
24
24
|
end
|
25
25
|
|
26
26
|
def update_usable_space
|
@@ -28,6 +28,28 @@ module Cats
|
|
28
28
|
self.usable_space -= (gangway_length * gangway_width) if has_gangway
|
29
29
|
self.available_space = self.usable_space
|
30
30
|
end
|
31
|
+
|
32
|
+
def self.ransackable_attributes(auth_object = nil)
|
33
|
+
[
|
34
|
+
"available_space",
|
35
|
+
"code",
|
36
|
+
"gangway_corner_dist",
|
37
|
+
"gangway_length",
|
38
|
+
"gangway_width",
|
39
|
+
"has_gangway",
|
40
|
+
"height",
|
41
|
+
"length",
|
42
|
+
"name",
|
43
|
+
"temporary",
|
44
|
+
"usable_space",
|
45
|
+
"warehouse_id",
|
46
|
+
"width"
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.ransackable_associations(auth_object = nil)
|
51
|
+
["stacks", "warehouse"]
|
52
|
+
end
|
31
53
|
end
|
32
54
|
end
|
33
55
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Swap < ApplicationRecord
|
4
|
-
belongs_to :issued_commodity, class_name:
|
5
|
-
belongs_to :issued_unit, class_name:
|
6
|
-
belongs_to :received_commodity, class_name:
|
7
|
-
belongs_to :received_unit, class_name:
|
4
|
+
belongs_to :issued_commodity, class_name: "CommodityCategory"
|
5
|
+
belongs_to :issued_unit, class_name: "UnitOfMeasure"
|
6
|
+
belongs_to :received_commodity, class_name: "CommodityCategory"
|
7
|
+
belongs_to :received_unit, class_name: "UnitOfMeasure"
|
8
8
|
|
9
9
|
validates :reference_no, presence: true, uniqueness: true
|
10
10
|
validates :swapper, :agreement_date, :issued_quantity, :received_quantity, presence: true
|
11
|
-
validates :issued_quantity, :received_quantity, presence: true, numericality: {
|
11
|
+
validates :issued_quantity, :received_quantity, presence: true, numericality: {greater_than: 0}
|
12
12
|
|
13
13
|
delegate(:name, to: :issued_commodity, prefix: true)
|
14
14
|
delegate(:name, to: :received_commodity, prefix: true)
|
@@ -5,20 +5,20 @@ module Cats
|
|
5
5
|
after_initialize :set_status
|
6
6
|
|
7
7
|
# Transaction statuses
|
8
|
-
DRAFT =
|
9
|
-
COMMITTED =
|
8
|
+
DRAFT = "Draft".freeze
|
9
|
+
COMMITTED = "Committed".freeze
|
10
10
|
STATUSES = [DRAFT, COMMITTED].freeze
|
11
11
|
|
12
|
-
belongs_to :unit, class_name:
|
12
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
13
13
|
|
14
14
|
validates :transaction_date, :quantity, :status, presence: true
|
15
|
-
validates :quantity, numericality: {
|
16
|
-
validates :status, inclusion: {
|
15
|
+
validates :quantity, numericality: {greater_than: 0}
|
16
|
+
validates :status, inclusion: {in: STATUSES}
|
17
17
|
|
18
18
|
delegate(:abbreviation, to: :unit, prefix: true)
|
19
19
|
|
20
20
|
def commit
|
21
|
-
raise(NotImplementedError,
|
21
|
+
raise(NotImplementedError, "Method should be implemented in child classes.")
|
22
22
|
end
|
23
23
|
|
24
24
|
def set_status
|
@@ -1,36 +1,36 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class TransportBid < ApplicationRecord
|
4
|
-
NEW =
|
5
|
-
OPEN =
|
6
|
-
CLOSED =
|
7
|
-
RANKED =
|
8
|
-
WINNERS_DECLARED =
|
4
|
+
NEW = "New".freeze
|
5
|
+
OPEN = "Open".freeze
|
6
|
+
CLOSED = "Closed".freeze
|
7
|
+
RANKED = "Ranked".freeze
|
8
|
+
WINNERS_DECLARED = "Winner Declared".freeze
|
9
9
|
STATUSES = [NEW, OPEN, CLOSED, RANKED, WINNERS_DECLARED].freeze
|
10
10
|
|
11
11
|
has_many :transport_bid_items
|
12
12
|
has_many :transport_offers
|
13
13
|
has_many :offer_items, through: :transport_offers
|
14
14
|
has_many :tenderers
|
15
|
-
belongs_to :region, class_name:
|
15
|
+
belongs_to :region, class_name: "Cats::Core::Location", optional: true
|
16
16
|
belongs_to :transport_plan
|
17
17
|
|
18
18
|
validates :reference_no, presence: true, uniqueness: true
|
19
19
|
validates :start_date, :end_date, :opening_date, :status, :bid_bond_amount, presence: true
|
20
|
-
validates :bid_bond_amount, numericality: {
|
21
|
-
validates :status, inclusion: {
|
20
|
+
validates :bid_bond_amount, numericality: {greater_than_or_equal_to: 0}
|
21
|
+
validates :status, inclusion: {in: STATUSES}
|
22
22
|
validate :validate_start_date_against_end_date
|
23
23
|
|
24
24
|
def validate_start_date_against_end_date
|
25
25
|
return unless start_date && end_date
|
26
26
|
|
27
|
-
errors.add(:start_date,
|
27
|
+
errors.add(:start_date, "should be before end date.") if start_date >= end_date
|
28
28
|
end
|
29
29
|
|
30
30
|
def open
|
31
|
-
raise(StandardError,
|
31
|
+
raise(StandardError, "Bid is already open.") if status == OPEN
|
32
32
|
|
33
|
-
raise(StandardError,
|
33
|
+
raise(StandardError, "Bid is empty.") if transport_bid_items.count.zero?
|
34
34
|
|
35
35
|
self.status = OPEN
|
36
36
|
save!
|
@@ -38,9 +38,9 @@ module Cats
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def close
|
41
|
-
raise(StandardError,
|
41
|
+
raise(StandardError, "Bid is already closed.") if status == CLOSED
|
42
42
|
|
43
|
-
raise(StandardError,
|
43
|
+
raise(StandardError, "Bid should first be open.") if status == NEW
|
44
44
|
|
45
45
|
self.status = CLOSED
|
46
46
|
save!
|
@@ -3,11 +3,11 @@ module Cats
|
|
3
3
|
class TransportBidItem < ApplicationRecord
|
4
4
|
belongs_to :transport_bid
|
5
5
|
belongs_to :transport_plan_item
|
6
|
-
belongs_to :unit, class_name:
|
6
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
7
7
|
|
8
8
|
has_many :offer_items
|
9
9
|
|
10
|
-
validates :quantity, presence: true, numericality: {
|
10
|
+
validates :quantity, presence: true, numericality: {greater_than: 0}
|
11
11
|
validates :transport_plan_item_id, uniqueness: true
|
12
12
|
|
13
13
|
delegate(:reference_no, to: :transport_bid, prefix: true)
|
@@ -6,11 +6,11 @@ module Cats
|
|
6
6
|
has_many :offer_items
|
7
7
|
|
8
8
|
validates :offer_date, :bid_bond_amount, presence: true
|
9
|
-
validates :bid_bond_amount, numericality: {
|
10
|
-
validates :transport_bid_id, uniqueness: {
|
9
|
+
validates :bid_bond_amount, numericality: {greater_than_or_equal_to: 0}
|
10
|
+
validates :transport_bid_id, uniqueness: {scope: :transporter_id}
|
11
11
|
|
12
12
|
delegate(:name, to: :transporter, prefix: true)
|
13
|
-
delegate(:reference_no, to: :transport_bid, prefix:
|
13
|
+
delegate(:reference_no, to: :transport_bid, prefix: "bid")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class TransportOrder < ApplicationRecord
|
4
|
-
DRAFT =
|
5
|
-
APPROVED =
|
4
|
+
DRAFT = "Draft".freeze
|
5
|
+
APPROVED = "Approved".freeze
|
6
6
|
STATUSES = [DRAFT, APPROVED].freeze
|
7
7
|
|
8
8
|
belongs_to :transport_requisition
|
9
|
-
belongs_to :prepared_by, class_name:
|
10
|
-
belongs_to :approved_by, class_name:
|
9
|
+
belongs_to :prepared_by, class_name: "Cats::Core::User"
|
10
|
+
belongs_to :approved_by, class_name: "Cats::Core::User", optional: true
|
11
11
|
|
12
12
|
has_many :transport_order_items
|
13
13
|
|
14
|
-
validates :status, presence: true, inclusion: {
|
14
|
+
validates :status, presence: true, inclusion: {in: STATUSES}
|
15
15
|
validates :order_date, presence: true
|
16
16
|
validate :validate_against_requisition, :validate_status
|
17
17
|
|
18
18
|
delegate(:full_name, to: :prepared_by, prefix: true)
|
19
19
|
delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
|
20
|
-
delegate(:reference_no, to: :transport_requisition, prefix:
|
20
|
+
delegate(:reference_no, to: :transport_requisition, prefix: "requisition")
|
21
21
|
|
22
22
|
def validate_against_requisition
|
23
23
|
return unless transport_requisition
|
24
24
|
|
25
25
|
return if transport_requisition.approved?
|
26
26
|
|
27
|
-
errors.add(:transport_requisition,
|
27
|
+
errors.add(:transport_requisition, "is not approved.")
|
28
28
|
end
|
29
29
|
|
30
30
|
def validate_status
|
@@ -38,7 +38,7 @@ module Cats
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def approve(user)
|
41
|
-
raise(StandardError,
|
41
|
+
raise(StandardError, "Transport order is already approved.") if status == APPROVED
|
42
42
|
|
43
43
|
begin
|
44
44
|
self.status = APPROVED
|
@@ -7,7 +7,7 @@ module Cats
|
|
7
7
|
belongs_to :transport_contract, optional: true
|
8
8
|
|
9
9
|
validates :valid_for, presence: true
|
10
|
-
validates :valid_for, numericality: {
|
10
|
+
validates :valid_for, numericality: {greater_than: 0}
|
11
11
|
validates :transport_requisition_item_id, uniqueness: true
|
12
12
|
validate :validate_requisition
|
13
13
|
|
@@ -21,7 +21,7 @@ module Cats
|
|
21
21
|
|
22
22
|
return if transport_order.transport_requisition_id == transport_requisition_item.transport_requisition_id
|
23
23
|
|
24
|
-
errors.add(:transport_requisition_item,
|
24
|
+
errors.add(:transport_requisition_item, "does not belong to the requisition of the order.")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -2,15 +2,15 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class TransportPlan < ApplicationRecord
|
4
4
|
# Plan types
|
5
|
-
REGIONAL =
|
6
|
-
NON_REGIONAL =
|
5
|
+
REGIONAL = "Regional".freeze
|
6
|
+
NON_REGIONAL = "Non Regional".freeze
|
7
7
|
PLAN_TYPES = [REGIONAL, NON_REGIONAL].freeze
|
8
8
|
|
9
|
-
belongs_to :region, class_name:
|
9
|
+
belongs_to :region, class_name: "Cats::Core::Location", optional: true
|
10
10
|
has_many :transport_plan_items
|
11
11
|
|
12
12
|
validates :reference_no, presence: true, uniqueness: true
|
13
|
-
validates :plan_type, presence: true, inclusion: {
|
13
|
+
validates :plan_type, presence: true, inclusion: {in: PLAN_TYPES}
|
14
14
|
validate :validate_region
|
15
15
|
|
16
16
|
delegate(:name, to: :region, prefix: true)
|
@@ -18,11 +18,11 @@ module Cats
|
|
18
18
|
def validate_region
|
19
19
|
return unless plan_type
|
20
20
|
|
21
|
-
errors.add(:region,
|
21
|
+
errors.add(:region, "should be null.") if plan_type == NON_REGIONAL && region
|
22
22
|
|
23
|
-
errors.add(:region,
|
23
|
+
errors.add(:region, "should not be null.") if plan_type == REGIONAL && !region
|
24
24
|
|
25
|
-
errors.add(:region,
|
25
|
+
errors.add(:region, "is not valid.") if region && region.location_type != Location::REGION
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -3,9 +3,9 @@ module Cats
|
|
3
3
|
class TransportPlanItem < ApplicationRecord
|
4
4
|
belongs_to :route
|
5
5
|
belongs_to :transport_plan
|
6
|
-
belongs_to :unit, class_name:
|
6
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
7
7
|
|
8
|
-
validates :quantity, presence: true, numericality: {
|
8
|
+
validates :quantity, presence: true, numericality: {greater_than: 0}
|
9
9
|
|
10
10
|
delegate(:name, to: :route, prefix: true)
|
11
11
|
delegate(:name, to: :unit, prefix: true)
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class TransportRequisition < ApplicationRecord
|
4
|
-
DRAFT =
|
5
|
-
APPROVED =
|
4
|
+
DRAFT = "Draft".freeze
|
5
|
+
APPROVED = "Approved".freeze
|
6
6
|
STATUSES = [DRAFT, APPROVED].freeze
|
7
7
|
|
8
8
|
belongs_to :dispatch_plan
|
9
|
-
belongs_to :requested_by, class_name:
|
10
|
-
belongs_to :approved_by, class_name:
|
11
|
-
belongs_to :unit, class_name:
|
9
|
+
belongs_to :requested_by, class_name: "Cats::Core::User"
|
10
|
+
belongs_to :approved_by, class_name: "Cats::Core::User", optional: true
|
11
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
12
12
|
|
13
13
|
has_many :transport_requisition_items
|
14
14
|
|
15
15
|
validates :reference_no, presence: true, uniqueness: true
|
16
|
-
validates :status, presence: true, inclusion: {
|
16
|
+
validates :status, presence: true, inclusion: {in: STATUSES}
|
17
17
|
validate :validate_status
|
18
18
|
|
19
|
-
delegate(:full_name, to: :requested_by, prefix:
|
20
|
-
delegate(:full_name, to: :approved_by, prefix:
|
19
|
+
delegate(:full_name, to: :requested_by, prefix: "requestor")
|
20
|
+
delegate(:full_name, to: :approved_by, prefix: "approver", allow_nil: true)
|
21
21
|
delegate(:abbreviation, to: :unit, prefix: true)
|
22
22
|
delegate(:reference_no, to: :dispatch_plan, prefix: true)
|
23
23
|
delegate(:region, to: :dispatch_plan)
|
@@ -28,7 +28,7 @@ module Cats
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def approve(user)
|
31
|
-
raise(StandardError,
|
31
|
+
raise(StandardError, "Transport requisition is already approved.") if status == APPROVED
|
32
32
|
|
33
33
|
begin
|
34
34
|
self.status = APPROVED
|
@@ -2,9 +2,9 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class TransportRequisitionDetail < ApplicationRecord
|
4
4
|
belongs_to :transport_requisition_item
|
5
|
-
belongs_to :fdp, class_name:
|
5
|
+
belongs_to :fdp, class_name: "Cats::Core::Location"
|
6
6
|
|
7
|
-
validates :quantity, presence: true, numericality: {
|
7
|
+
validates :quantity, presence: true, numericality: {greater_than: 0}
|
8
8
|
|
9
9
|
delegate(:name, to: :fdp, prefix: true)
|
10
10
|
end
|
@@ -3,11 +3,11 @@ module Cats
|
|
3
3
|
class TransportRequisitionItem < ApplicationRecord
|
4
4
|
belongs_to :transport_requisition
|
5
5
|
belongs_to :dispatch_plan_item
|
6
|
-
belongs_to :unit, class_name:
|
6
|
+
belongs_to :unit, class_name: "Cats::Core::UnitOfMeasure"
|
7
7
|
|
8
|
-
validates :quantity, presence: true, numericality: {
|
8
|
+
validates :quantity, presence: true, numericality: {greater_than: 0}
|
9
9
|
|
10
|
-
delegate(:reference_no, to: :transport_requisition, prefix:
|
10
|
+
delegate(:reference_no, to: :transport_requisition, prefix: "requisition")
|
11
11
|
delegate(:abbreviation, to: :unit, prefix: true)
|
12
12
|
delegate(:source_name, to: :dispatch_plan_item, prefix: false)
|
13
13
|
|
@@ -3,6 +3,10 @@ module Cats
|
|
3
3
|
class Transporter < ApplicationRecord
|
4
4
|
validates :code, :name, :address, :contact_phone, presence: true
|
5
5
|
validates :code, uniqueness: true
|
6
|
+
|
7
|
+
def self.ransackable_attributes(auth_object = nil)
|
8
|
+
["address", "code", "contact_phone", "name"]
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
12
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class UnitConversion < ApplicationRecord
|
4
|
-
belongs_to :from, class_name:
|
5
|
-
belongs_to :to, class_name:
|
4
|
+
belongs_to :from, class_name: "Cats::Core::UnitOfMeasure"
|
5
|
+
belongs_to :to, class_name: "Cats::Core::UnitOfMeasure"
|
6
6
|
|
7
7
|
validates :factor, presence: true
|
8
|
-
validates :from_id, uniqueness: {
|
9
|
-
validates :factor, numericality: {
|
8
|
+
validates :from_id, uniqueness: {scope: :to_id}
|
9
|
+
validates :factor, numericality: {greater_than: 0}
|
10
10
|
|
11
11
|
delegate(:abbreviation, to: :from, prefix: true)
|
12
12
|
delegate(:abbreviation, to: :to, prefix: true)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class UnitOfMeasure < ApplicationRecord
|
4
|
-
WEIGHT =
|
5
|
-
VOLUME =
|
6
|
-
ITEM =
|
4
|
+
WEIGHT = "Weight".freeze
|
5
|
+
VOLUME = "Volume".freeze
|
6
|
+
ITEM = "Item".freeze
|
7
7
|
UNIT_TYPES = [WEIGHT, VOLUME, ITEM].freeze
|
8
8
|
|
9
9
|
validates :name, :abbreviation, presence: true, uniqueness: true
|
10
|
-
validates :unit_type, presence: true, inclusion: {
|
10
|
+
validates :unit_type, presence: true, inclusion: {in: UNIT_TYPES}
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|