cats_core 1.2.17 → 1.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/donation.rb +2 -2
- data/app/models/cats/core/{hrp.rb → plan.rb} +2 -2
- data/app/models/cats/core/{hrp_item.rb → plan_item.rb} +4 -4
- data/app/models/cats/core/{hrp_item_detail.rb → plan_item_detail.rb} +3 -3
- data/app/models/cats/core/transport_bid.rb +22 -0
- data/app/models/cats/core/transport_bid_item.rb +1 -0
- data/db/migrate/{20210717031810_create_cats_core_hrps.rb → 20210717031810_create_cats_core_plans.rb} +4 -4
- data/db/migrate/20210717032024_create_cats_core_plan_items.rb +23 -0
- data/db/migrate/20210717032240_create_cats_core_plan_item_details.rb +18 -0
- data/db/migrate/20210717032330_create_cats_core_donations.rb +3 -3
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/donations.rb +1 -1
- data/spec/factories/cats/core/plan_item_details.rb +7 -0
- data/spec/factories/cats/core/{hrp_items.rb → plan_items.rb} +2 -2
- data/spec/factories/cats/core/plans.rb +10 -0
- metadata +11 -11
- data/db/migrate/20210717032024_create_cats_core_hrp_items.rb +0 -23
- data/db/migrate/20210717032240_create_cats_core_hrp_item_details.rb +0 -18
- data/spec/factories/cats/core/hrp_item_details.rb +0 -7
- data/spec/factories/cats/core/hrps.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7acc9223402378e3d0708d5868c80f1bbff5bf9f22db440a9ef298834ca886df
|
4
|
+
data.tar.gz: aae5042083532d9ec3d31b5c13cee75d060539b53ddb97da52f1b65f6529422b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a7c5f08aaac792fe9f745f552fceb45968d2cef9b627916af18205466897051331f52620b720b000b9b07ae4e301f9ee473669caa22c8f64ee63a1ce39e7e19
|
7
|
+
data.tar.gz: f7b9292e6e8173f0aec82e71ced97b11dad6f16882763d4fb6b91c788d2b1db60df38ef5f35961930800cebf6308cc42576127d76cb2e2560eb853b4bc0ed6f8
|
@@ -6,7 +6,7 @@ module Cats
|
|
6
6
|
DONATION_TYPES = [CASH, KIND].freeze
|
7
7
|
|
8
8
|
belongs_to :donor
|
9
|
-
belongs_to :
|
9
|
+
belongs_to :plan
|
10
10
|
belongs_to :currency, optional: true
|
11
11
|
belongs_to :commodity_category, optional: true
|
12
12
|
belongs_to :unit_of_measure, optional: true
|
@@ -19,7 +19,7 @@ module Cats
|
|
19
19
|
validates :unit_of_measure, presence: true, if: -> { donation_type == KIND }
|
20
20
|
|
21
21
|
delegate(:name, to: :donor, prefix: true)
|
22
|
-
delegate(:reference_no, to: :
|
22
|
+
delegate(:reference_no, to: :plan, prefix: true)
|
23
23
|
delegate(:name, to: :commodity_category, prefix: true, allow_nil: true)
|
24
24
|
delegate(:code, to: :currency, prefix: true, allow_nil: true)
|
25
25
|
delegate(:abbreviation, to: :unit_of_measure, prefix: true, allow_nil: true)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
|
-
class
|
3
|
+
class Plan < ApplicationRecord
|
4
4
|
DRAFT = 'Draft'.freeze
|
5
5
|
APPROVED = 'Approved'.freeze
|
6
6
|
NEEDS_APPROVED = 'Needs Approved'.freeze
|
@@ -13,7 +13,7 @@ module Cats
|
|
13
13
|
|
14
14
|
belongs_to :program
|
15
15
|
belongs_to :ration, optional: true
|
16
|
-
has_many :
|
16
|
+
has_many :plan_items
|
17
17
|
|
18
18
|
validates :reference_no, :year, :status, presence: true
|
19
19
|
validates :season, presence: true, inclusion: { in: SEASONS }
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
|
-
class
|
4
|
-
belongs_to :
|
3
|
+
class PlanItem < ApplicationRecord
|
4
|
+
belongs_to :plan
|
5
5
|
belongs_to :woreda, -> { where(location_type: Cats::Core::Location::WOREDA) }, class_name: 'Cats::Core::Location'
|
6
6
|
belongs_to :operator
|
7
7
|
|
8
|
-
has_many :
|
8
|
+
has_many :plan_item_details
|
9
9
|
|
10
10
|
validates :beneficiaries, presence: true, numericality: { greater_than: 0 }
|
11
|
-
validates :
|
11
|
+
validates :plan_id, uniqueness: { scope: :woreda_id }
|
12
12
|
|
13
13
|
delegate(:name, to: :woreda, prefix: true)
|
14
14
|
delegate(:name, to: :operator, prefix: true)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
|
-
class
|
4
|
-
belongs_to :
|
3
|
+
class PlanItemDetail < ApplicationRecord
|
4
|
+
belongs_to :plan_item
|
5
5
|
belongs_to :ration_item
|
6
6
|
|
7
7
|
validates :amount, presence: true, numericality: { greater_than: 0 }
|
8
|
-
validates :
|
8
|
+
validates :plan_item_id, uniqueness: { scope: :ration_item_id }
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -6,6 +6,8 @@ module Cats
|
|
6
6
|
CLOSED = 'Closed'.freeze
|
7
7
|
STATUSES = [NEW, OPEN, CLOSED].freeze
|
8
8
|
|
9
|
+
has_many :transport_bid_items
|
10
|
+
|
9
11
|
validates :reference_no, presence: true, uniqueness: true
|
10
12
|
validates :start_date, :end_date, :status, presence: true
|
11
13
|
validates :status, inclusion: { in: STATUSES }
|
@@ -16,6 +18,26 @@ module Cats
|
|
16
18
|
|
17
19
|
errors.add(:start_date, 'should be before end date.') if start_date >= end_date
|
18
20
|
end
|
21
|
+
|
22
|
+
def open
|
23
|
+
raise(StandardError, 'Bid is already open.') if status == OPEN
|
24
|
+
|
25
|
+
raise(StandardError, 'Bid is empty.') if transport_bid_items.count.zero?
|
26
|
+
|
27
|
+
self.status = OPEN
|
28
|
+
save!
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def close
|
33
|
+
raise(StandardError, 'Bid is already closed.') if status == CLOSED
|
34
|
+
|
35
|
+
raise(StandardError, 'Bid should first be open.') if status == NEW
|
36
|
+
|
37
|
+
self.status = CLOSED
|
38
|
+
save!
|
39
|
+
self
|
40
|
+
end
|
19
41
|
end
|
20
42
|
end
|
21
43
|
end
|
data/db/migrate/{20210717031810_create_cats_core_hrps.rb → 20210717031810_create_cats_core_plans.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
class
|
1
|
+
class CreateCatsCorePlans < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :cats_core_plans do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
5
|
t.integer :year, null: false
|
6
6
|
t.string :season, null: false
|
@@ -8,11 +8,11 @@ class CreateCatsCoreHrps < ActiveRecord::Migration[6.1]
|
|
8
8
|
|
9
9
|
t.references :program,
|
10
10
|
null: false,
|
11
|
-
index: { name: '
|
11
|
+
index: { name: 'program_on_plan_indx' },
|
12
12
|
foreign_key: { to_table: :cats_core_programs }
|
13
13
|
t.references :ration,
|
14
14
|
null: true,
|
15
|
-
index: { name: '
|
15
|
+
index: { name: 'ration_on_plan_indx' },
|
16
16
|
foreign_key: { to_table: :cats_core_rations }
|
17
17
|
|
18
18
|
t.timestamps
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateCatsCorePlanItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_plan_items do |t|
|
4
|
+
t.references :plan,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'plan_on_plan_items_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_plans }
|
8
|
+
t.references :woreda,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'woreda_on_plan_items_idnx' },
|
11
|
+
foreign_key: { to_table: :cats_core_locations }
|
12
|
+
t.integer :beneficiaries, null: false
|
13
|
+
t.references :operator,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'operator_on_plan_items_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_operators }
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
|
21
|
+
add_index :cats_core_plan_items, [:plan_id, :woreda_id], unique: true
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateCatsCorePlanItemDetails < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_plan_item_details do |t|
|
4
|
+
t.references :plan_item,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'pi_on_pid_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_plan_items }
|
8
|
+
t.references :ration_item,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'ri_on_pid_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_ration_items }
|
12
|
+
t.float :amount, null: false
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
add_index(:cats_core_plan_item_details, [:plan_item_id, :ration_item_id], unique: true, name: 'pii_rii_on_pid_indx')
|
17
|
+
end
|
18
|
+
end
|
@@ -8,10 +8,10 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
|
|
8
8
|
null: false,
|
9
9
|
index: { name: 'donor_on_donation_indx' },
|
10
10
|
foreign_key: { to_table: :cats_core_donors }
|
11
|
-
t.references :
|
11
|
+
t.references :plan,
|
12
12
|
null: false,
|
13
|
-
index: { name: '
|
14
|
-
foreign_key: { to_table: :
|
13
|
+
index: { name: 'plan_on_donation_indx' },
|
14
|
+
foreign_key: { to_table: :cats_core_plans }
|
15
15
|
t.float :amount, null: false
|
16
16
|
t.references :currency,
|
17
17
|
null: true,
|
data/lib/cats/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -265,15 +265,15 @@ files:
|
|
265
265
|
- app/models/cats/core/donation.rb
|
266
266
|
- app/models/cats/core/donor.rb
|
267
267
|
- app/models/cats/core/gift_certificate.rb
|
268
|
-
- app/models/cats/core/hrp.rb
|
269
|
-
- app/models/cats/core/hrp_item.rb
|
270
|
-
- app/models/cats/core/hrp_item_detail.rb
|
271
268
|
- app/models/cats/core/location.rb
|
272
269
|
- app/models/cats/core/menu.rb
|
273
270
|
- app/models/cats/core/menu_item.rb
|
274
271
|
- app/models/cats/core/notification.rb
|
275
272
|
- app/models/cats/core/notification_rule.rb
|
276
273
|
- app/models/cats/core/operator.rb
|
274
|
+
- app/models/cats/core/plan.rb
|
275
|
+
- app/models/cats/core/plan_item.rb
|
276
|
+
- app/models/cats/core/plan_item_detail.rb
|
277
277
|
- app/models/cats/core/program.rb
|
278
278
|
- app/models/cats/core/purchase_order.rb
|
279
279
|
- app/models/cats/core/ration.rb
|
@@ -341,9 +341,9 @@ files:
|
|
341
341
|
- db/migrate/20210717031108_create_cats_core_donors.rb
|
342
342
|
- db/migrate/20210717031216_create_cats_core_rations.rb
|
343
343
|
- db/migrate/20210717031343_create_cats_core_ration_items.rb
|
344
|
-
- db/migrate/
|
345
|
-
- db/migrate/
|
346
|
-
- db/migrate/
|
344
|
+
- db/migrate/20210717031810_create_cats_core_plans.rb
|
345
|
+
- db/migrate/20210717032024_create_cats_core_plan_items.rb
|
346
|
+
- db/migrate/20210717032240_create_cats_core_plan_item_details.rb
|
347
347
|
- db/migrate/20210717032330_create_cats_core_donations.rb
|
348
348
|
- db/migrate/20210717032602_create_cats_core_gift_certificates.rb
|
349
349
|
- db/migrate/20210717032855_create_cats_core_purchase_orders.rb
|
@@ -391,15 +391,15 @@ files:
|
|
391
391
|
- spec/factories/cats/core/donations.rb
|
392
392
|
- spec/factories/cats/core/donors.rb
|
393
393
|
- spec/factories/cats/core/gift_certificates.rb
|
394
|
-
- spec/factories/cats/core/hrp_item_details.rb
|
395
|
-
- spec/factories/cats/core/hrp_items.rb
|
396
|
-
- spec/factories/cats/core/hrps.rb
|
397
394
|
- spec/factories/cats/core/locations.rb
|
398
395
|
- spec/factories/cats/core/menu_items.rb
|
399
396
|
- spec/factories/cats/core/menus.rb
|
400
397
|
- spec/factories/cats/core/notification_rules.rb
|
401
398
|
- spec/factories/cats/core/notifications.rb
|
402
399
|
- spec/factories/cats/core/operators.rb
|
400
|
+
- spec/factories/cats/core/plan_item_details.rb
|
401
|
+
- spec/factories/cats/core/plan_items.rb
|
402
|
+
- spec/factories/cats/core/plans.rb
|
403
403
|
- spec/factories/cats/core/programs.rb
|
404
404
|
- spec/factories/cats/core/purchase_orders.rb
|
405
405
|
- spec/factories/cats/core/ration_items.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class CreateCatsCoreHrpItems < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_hrp_items do |t|
|
4
|
-
t.references :hrp,
|
5
|
-
null: false,
|
6
|
-
index: { name: 'hrp_on_hrp_items_indx' },
|
7
|
-
foreign_key: { to_table: :cats_core_hrps }
|
8
|
-
t.references :woreda,
|
9
|
-
null: false,
|
10
|
-
index: { name: 'woreda_on_hrp_items_idnx' },
|
11
|
-
foreign_key: { to_table: :cats_core_locations }
|
12
|
-
t.integer :beneficiaries, null: false
|
13
|
-
t.references :operator,
|
14
|
-
null: false,
|
15
|
-
index: { name: 'operator_on_hrp_items_indx' },
|
16
|
-
foreign_key: { to_table: :cats_core_operators }
|
17
|
-
|
18
|
-
t.timestamps
|
19
|
-
end
|
20
|
-
|
21
|
-
add_index :cats_core_hrp_items, [:hrp_id, :woreda_id], unique: true
|
22
|
-
end
|
23
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class CreateCatsCoreHrpItemDetails < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_hrp_item_details do |t|
|
4
|
-
t.references :hrp_item,
|
5
|
-
null: false,
|
6
|
-
index: { name: 'hi_on_hid_indx' },
|
7
|
-
foreign_key: { to_table: :cats_core_hrp_items }
|
8
|
-
t.references :ration_item,
|
9
|
-
null: false,
|
10
|
-
index: { name: 'ri_on_hid_indx' },
|
11
|
-
foreign_key: { to_table: :cats_core_ration_items }
|
12
|
-
t.float :amount, null: false
|
13
|
-
|
14
|
-
t.timestamps
|
15
|
-
end
|
16
|
-
add_index(:cats_core_hrp_item_details, [:hrp_item_id, :ration_item_id], unique: true, name: 'hii_rii_on_hid_indx')
|
17
|
-
end
|
18
|
-
end
|