cats_core 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +10 -0
- data/app/controllers/cats/core/application_controller.rb +4 -0
- data/app/models/cats/core/application_module.rb +8 -0
- data/app/models/cats/core/application_record.rb +7 -0
- data/app/models/cats/core/commodity.rb +17 -0
- data/app/models/cats/core/commodity_category.rb +8 -0
- data/app/models/cats/core/commodity_transaction.rb +55 -0
- data/app/models/cats/core/donor.rb +8 -0
- data/app/models/cats/core/location.rb +48 -0
- data/app/models/cats/core/menu.rb +9 -0
- data/app/models/cats/core/menu_item.rb +9 -0
- data/app/models/cats/core/program.rb +8 -0
- data/app/models/cats/core/role.rb +9 -0
- data/app/models/cats/core/role_menu.rb +19 -0
- data/app/models/cats/core/stack.rb +39 -0
- data/app/models/cats/core/store.rb +24 -0
- data/app/models/cats/core/transporter.rb +8 -0
- data/app/models/cats/core/unit_of_measure.rb +13 -0
- data/app/models/cats/core/user.rb +14 -0
- data/app/models/cats/core/way_bill.rb +12 -0
- data/app/models/cats/core/way_bill_item.rb +15 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20210715114238_create_cats_core_application_modules.rb +10 -0
- data/db/migrate/20210715114910_create_cats_core_users.rb +18 -0
- data/db/migrate/20210715120018_create_cats_core_roles.rb +28 -0
- data/db/migrate/20210715121244_create_cats_core_menus.rb +14 -0
- data/db/migrate/20210715122141_create_cats_core_menu_items.rb +15 -0
- data/db/migrate/20210715122423_create_cats_core_role_menus.rb +28 -0
- data/db/migrate/20210716124953_create_cats_core_commodity_categories.rb +12 -0
- data/db/migrate/20210716145125_create_cats_core_unit_of_measures.rb +11 -0
- data/db/migrate/20210716151230_create_cats_core_programs.rb +11 -0
- data/db/migrate/20210717031108_create_cats_core_donors.rb +10 -0
- data/db/migrate/20210717033223_create_cats_core_commodities.rb +28 -0
- data/db/migrate/20210717043620_create_cats_core_locations.rb +13 -0
- data/db/migrate/20210717140855_create_cats_core_stores.rb +23 -0
- data/db/migrate/20210717171101_create_cats_core_stacks.rb +25 -0
- data/db/migrate/20210718042749_create_cats_core_transporters.rb +12 -0
- data/db/migrate/20210718045516_create_cats_core_way_bills.rb +25 -0
- data/db/migrate/20210718050751_create_cats_core_way_bill_items.rb +18 -0
- data/db/migrate/20210718202957_create_cats_core_commodity_transactions.rb +14 -0
- data/lib/cats/core.rb +4 -0
- data/lib/cats/core/engine.rb +24 -0
- data/lib/cats/core/version.rb +5 -0
- data/lib/cats_core.rb +4 -0
- data/lib/tasks/cats_core_tasks.rake +4 -0
- data/spec/factories/cats/core/application_modules.rb +6 -0
- data/spec/factories/cats/core/commodities.rb +12 -0
- data/spec/factories/cats/core/commodity_categories.rb +8 -0
- data/spec/factories/cats/core/commodity_transactions.rb +10 -0
- data/spec/factories/cats/core/donors.rb +6 -0
- data/spec/factories/cats/core/locations.rb +12 -0
- data/spec/factories/cats/core/menu_items.rb +8 -0
- data/spec/factories/cats/core/menus.rb +7 -0
- data/spec/factories/cats/core/programs.rb +7 -0
- data/spec/factories/cats/core/role_menus.rb +12 -0
- data/spec/factories/cats/core/roles.rb +6 -0
- data/spec/factories/cats/core/stacks.rb +15 -0
- data/spec/factories/cats/core/stores.rb +16 -0
- data/spec/factories/cats/core/transporters.rb +8 -0
- data/spec/factories/cats/core/unit_of_measures.rb +7 -0
- data/spec/factories/cats/core/users.rb +11 -0
- data/spec/factories/cats/core/way_bill_items.rb +8 -0
- data/spec/factories/cats/core/way_bills.rb +12 -0
- metadata +280 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateCatsCoreUsers < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_users do |t|
|
4
|
+
t.string :first_name, null: false
|
5
|
+
t.string :last_name, null: false
|
6
|
+
t.string :email, unique: true
|
7
|
+
t.boolean :active, null: false, default: true
|
8
|
+
t.string :password_digest
|
9
|
+
t.jsonb :details
|
10
|
+
t.references :application_module,
|
11
|
+
null: false,
|
12
|
+
index: { name: 'am_on_users_indx' },
|
13
|
+
foreign_key: { to_table: :cats_core_application_modules }
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateCatsCoreRoles < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table(:cats_core_roles) do |t|
|
4
|
+
t.string :name
|
5
|
+
t.references :resource, :polymorphic => true
|
6
|
+
t.references :application_module,
|
7
|
+
null: false,
|
8
|
+
index: { name: 'am_on_roles_indx' },
|
9
|
+
foreign_key: { to_table: :cats_core_application_modules }
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table(:cats_core_users_cats_core_roles, :id => false) do |t|
|
15
|
+
t.references :user,
|
16
|
+
null: false,
|
17
|
+
index: { name: 'user_on_ur_indx' },
|
18
|
+
foreign_key: { to_table: :cats_core_users }
|
19
|
+
t.references :role,
|
20
|
+
null: false,
|
21
|
+
index: { name: 'role_on_ur_indx' },
|
22
|
+
foreign_key: { to_table: :cats_core_roles }
|
23
|
+
end
|
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 ])
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateCatsCoreMenus < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_menus do |t|
|
4
|
+
t.string :label, null: false
|
5
|
+
t.string :icon
|
6
|
+
t.references :application_module,
|
7
|
+
null: false,
|
8
|
+
index: { name: 'am_on_menus_indx' },
|
9
|
+
foreign_key: { to_table: :cats_core_application_modules }
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateCatsCoreMenuItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_menu_items do |t|
|
4
|
+
t.string :label, null: false
|
5
|
+
t.string :icon
|
6
|
+
t.string :route, null: false
|
7
|
+
t.references :menu,
|
8
|
+
null: false,
|
9
|
+
index: { name: 'menu_on_mi_indx' },
|
10
|
+
foreign_key: { to_table: :cats_core_menus }
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateCatsCoreRoleMenus < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_role_menus do |t|
|
4
|
+
t.references :role,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'role_on_rm_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_roles }
|
8
|
+
t.references :menu,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'menu_on_rm_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_menus }
|
12
|
+
t.string :description
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table(:cats_core_role_menus_menu_items, :id => false) do |t|
|
18
|
+
t.references :role_menu,
|
19
|
+
null: false,
|
20
|
+
index: { name: 'rm_on_ummi_indx' },
|
21
|
+
foreign_key: { to_table: :cats_core_role_menus }
|
22
|
+
t.references :menu_item,
|
23
|
+
null: false,
|
24
|
+
index: { name: 'mi_on_ummi_indx' },
|
25
|
+
foreign_key: { to_table: :cats_core_menu_items }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateCatsCoreCommodityCategories < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodity_categories do |t|
|
4
|
+
t.string :code, unique: true
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :description
|
7
|
+
t.string :ancestry, index: true
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateCatsCoreUnitOfMeasures < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_unit_of_measures do |t|
|
4
|
+
t.string :name, unique: true
|
5
|
+
t.string :abbreviation, unique: true
|
6
|
+
t.string :unit_type, null: false
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateCatsCoreCommodities < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodities do |t|
|
4
|
+
t.references :commodity_category,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'cc_on_commodities_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
8
|
+
t.references :donor,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'donor_on_commodities_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_donors }
|
12
|
+
t.references :program,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'program_on_commodities_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_programs}
|
16
|
+
t.references :unit_of_measure,
|
17
|
+
null: false,
|
18
|
+
index: { name: 'uom_on_commodities_indx' },
|
19
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
20
|
+
t.float :quantity, null: false
|
21
|
+
t.string :description
|
22
|
+
t.boolean :hazardous, null: false, default: false
|
23
|
+
t.date :best_use_before
|
24
|
+
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateCatsCoreLocations < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_locations do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :location_type, null: false
|
6
|
+
t.string :description
|
7
|
+
t.string :ancestry
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :cats_core_locations, :ancestry
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateCatsCoreStores < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_stores do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :store_keeper_name, null: false
|
6
|
+
t.string :store_keeper_phone
|
7
|
+
t.float :length, null: false
|
8
|
+
t.float :width, null: false
|
9
|
+
t.float :height, null: false
|
10
|
+
t.boolean :temporary, null: false, default: false
|
11
|
+
t.boolean :has_gangway, null: false, default: false
|
12
|
+
t.float :gangway_length
|
13
|
+
t.float :gangway_width
|
14
|
+
t.float :gangway_corner_dist
|
15
|
+
t.references :warehouse,
|
16
|
+
null: false,
|
17
|
+
index: { name: 'warehouse_on_stores_indx' },
|
18
|
+
foreign_key: { to_table: :cats_core_locations }
|
19
|
+
|
20
|
+
t.timestamps
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateCatsCoreStacks < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_stacks do |t|
|
4
|
+
t.string :code, unique: true
|
5
|
+
t.float :length, null: false
|
6
|
+
t.float :width, null: false
|
7
|
+
t.float :height, null: false
|
8
|
+
t.float :start_x, null: false
|
9
|
+
t.float :start_y, null: false
|
10
|
+
t.references :commodity,
|
11
|
+
null: false,
|
12
|
+
index: { name: 'commodity_on_stack_indx' },
|
13
|
+
foreign_key: { to_table: :cats_core_commodities }
|
14
|
+
t.references :store,
|
15
|
+
null: false,
|
16
|
+
index: { name: 'store_on_stack_indx' },
|
17
|
+
foreign_key: { to_table: :cats_core_stores }
|
18
|
+
t.string :commodity_status, null: false, default: 'Good'
|
19
|
+
t.string :stack_status, null: false, default: 'Reserved'
|
20
|
+
t.float :quantity, null: false, default: 0
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateCatsCoreTransporters < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transporters do |t|
|
4
|
+
t.string :code, unique: true
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :address, null: false
|
7
|
+
t.string :contact_phone, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateCatsCoreWayBills < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_way_bills do |t|
|
4
|
+
t.string :ref_no, unique: true
|
5
|
+
t.references :source,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'source_on_wb_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_locations }
|
9
|
+
t.references :destination,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'destination_on_wb_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_locations }
|
13
|
+
t.references :transporter,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'transporter_on_wb_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_transporters }
|
17
|
+
t.string :plate_no, null: false
|
18
|
+
t.string :driver_name, null: false
|
19
|
+
t.string :driver_phone, null: false
|
20
|
+
t.date :date_prepared, null: false
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateCatsCoreWayBillItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_way_bill_items do |t|
|
4
|
+
t.references :way_bill,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'wb_on_wbi_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_way_bills }
|
8
|
+
t.references :commodity,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'commodity_on_wbi_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_commodities }
|
12
|
+
t.float :quantity, null: false
|
13
|
+
t.string :commodity_status, null: false
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateCatsCoreCommodityTransactions < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodity_transactions do |t|
|
4
|
+
t.references :source, polymorphic: true
|
5
|
+
t.references :destination, polymorphic: true
|
6
|
+
t.date :transaction_date, null: false
|
7
|
+
t.float :quantity, null: false
|
8
|
+
t.string :status, null: false, default: 'Draft'
|
9
|
+
t.string :transaction_type, null: false, default: 'Stack to Stack'
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/cats/core.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace Cats::Core
|
5
|
+
config.generators.api_only = true
|
6
|
+
|
7
|
+
config.generators do |g|
|
8
|
+
g.test_framework :rspec
|
9
|
+
g.fixture_replacement :factory_bot
|
10
|
+
g.factory_bot dir: 'spec/factories'
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer 'cats_core.factories', after: 'factory_bot.set_factory_paths' do
|
14
|
+
FactoryBot.definition_file_paths << File.expand_path('../../../spec/factories', __dir__) if defined?(FactoryBot)
|
15
|
+
end
|
16
|
+
|
17
|
+
initializer :append_migrations do |app|
|
18
|
+
unless app.root.to_s.match(root.to_s + File::SEPARATOR)
|
19
|
+
app.config.paths['db/migrate'].concat(config.paths['db/migrate'].expanded)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cats_core.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :commodity, class: 'Cats::Core::Commodity' do
|
3
|
+
association :commodity_category
|
4
|
+
description { FFaker::Name.name }
|
5
|
+
association :donor
|
6
|
+
association :program
|
7
|
+
association :unit_of_measure
|
8
|
+
quantity { 100 }
|
9
|
+
hazardous { false }
|
10
|
+
best_use_before { Date.today + 2.month }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :commodity_transaction, class: 'Cats::Core::CommodityTransaction' do
|
3
|
+
source factory: :stack
|
4
|
+
destination factory: :stack
|
5
|
+
transaction_date { Date.today }
|
6
|
+
quantity { 10 }
|
7
|
+
status { Cats::Core::CommodityTransaction::DRAFT }
|
8
|
+
transaction_type { Cats::Core::CommodityTransaction::STACK_TO_STACK }
|
9
|
+
end
|
10
|
+
end
|