cats_core 1.4.40 → 1.4.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cats/core/cash_donations_controller.rb +19 -0
- data/app/controllers/cats/core/commodity_donations_controller.rb +22 -0
- data/app/controllers/cats/core/dispatch_plans_controller.rb +24 -0
- data/app/controllers/cats/core/loans_controller.rb +20 -0
- data/app/controllers/cats/core/purchase_orders_controller.rb +24 -0
- data/app/controllers/cats/core/round_beneficiaries_controller.rb +49 -0
- data/app/controllers/cats/core/swaps_controller.rb +21 -0
- data/app/models/cats/core/beneficiary.rb +9 -0
- data/app/models/cats/core/cash_donation.rb +11 -0
- data/app/models/cats/core/commodity_donation.rb +15 -0
- data/app/models/cats/core/dispatch_plan.rb +1 -1
- data/app/models/cats/core/donation.rb +2 -16
- data/app/models/cats/core/gift_certificate.rb +3 -23
- data/app/models/cats/core/loan.rb +15 -0
- data/app/models/cats/core/plan.rb +4 -0
- data/app/models/cats/core/project.rb +1 -0
- data/app/models/cats/core/purchase_order.rb +5 -13
- data/app/models/cats/core/rhn_request.rb +4 -4
- data/app/models/cats/core/round_beneficiary.rb +16 -0
- data/app/models/cats/core/round_plan.rb +2 -4
- data/app/models/cats/core/round_plan_item.rb +1 -0
- data/app/models/cats/core/swap.rb +19 -0
- data/app/models/concerns/cats/core/dispatchable.rb +8 -0
- data/app/serializers/cats/core/cash_donation_serializer.rb +8 -0
- data/app/serializers/cats/core/commodity_donation_serializer.rb +9 -0
- data/app/serializers/cats/core/loan_serializer.rb +8 -0
- data/app/serializers/cats/core/purchase_order_serializer.rb +9 -0
- data/app/serializers/cats/core/round_beneficiary_serializer.rb +8 -0
- data/app/serializers/cats/core/swap_serializer.rb +9 -0
- data/app/services/cats/core/beneficiary_service.rb +87 -0
- data/app/services/cats/core/dispatch_plan_service.rb +79 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20210717032330_create_cats_core_commodity_donations.rb +29 -0
- data/db/migrate/20210717032408_create_cats_core_cash_donations.rb +20 -0
- data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +2 -8
- data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +9 -5
- data/db/migrate/20220511082354_create_cats_core_beneficiaries.rb +4 -0
- data/db/migrate/20220626063501_create_cats_core_loans.rb +21 -0
- data/db/migrate/20220626063757_create_cats_core_swaps.rb +29 -0
- data/db/migrate/20220626132050_create_cats_core_round_beneficiaries.rb +26 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/beneficiaries.rb +1 -0
- data/spec/factories/cats/core/cash_donations.rb +10 -0
- data/spec/factories/cats/core/{donations.rb → commodity_donations.rb} +3 -6
- data/spec/factories/cats/core/gift_certificates.rb +5 -6
- data/spec/factories/cats/core/loans.rb +11 -0
- data/spec/factories/cats/core/projects.rb +1 -1
- data/spec/factories/cats/core/purchase_orders.rb +3 -1
- data/spec/factories/cats/core/round_beneficiaries.rb +10 -0
- data/spec/factories/cats/core/swaps.rb +13 -0
- metadata +33 -7
- data/db/migrate/20210717032330_create_cats_core_donations.rb +0 -35
@@ -0,0 +1,87 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class BeneficiaryService
|
4
|
+
def clear_distribution_list(id)
|
5
|
+
round_plan = RoundPlan.find(id)
|
6
|
+
raise(StandardError, 'Round plan is not in draft state.') unless round_plan.status == RoundPlan::DRAFT
|
7
|
+
|
8
|
+
RoundBeneficiary.joins(:round_plan_item).where(round_plan_item: { round_plan_id: id }).delete_all
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_distribution_list(id)
|
12
|
+
clear_distribution_list(id)
|
13
|
+
round_plan = RoundPlan.find(id)
|
14
|
+
plan_days = round_plan.plan.no_of_round_days
|
15
|
+
rounds = round_plan.rounds.count
|
16
|
+
beneficiaries = Beneficiary.joins(:beneficiary_category).where(
|
17
|
+
beneficiary_category: { plan_id: round_plan.plan_id }
|
18
|
+
).group_by(&:fdp_id)
|
19
|
+
beneficiaries.each_key do |key|
|
20
|
+
beneficiaries[key] = beneficiaries[key].group_by(&:beneficiary_category_id)
|
21
|
+
end
|
22
|
+
rations = round_plan.round_rations
|
23
|
+
|
24
|
+
round_beneficiaries = []
|
25
|
+
round_plan.round_plan_items.each do |rpi|
|
26
|
+
fdp_beneficiaries = beneficiaries[rpi.fdp_id]
|
27
|
+
fdp_beneficiaries.each_key do |key|
|
28
|
+
category_rations = rations.select { |r| r.beneficiary_category_id == key }
|
29
|
+
category_rations.each do |ration|
|
30
|
+
fdp_beneficiaries[key].each do |beneficiary|
|
31
|
+
round_beneficiaries << {
|
32
|
+
beneficiary_id: beneficiary.id,
|
33
|
+
round_plan_item_id: rpi.id,
|
34
|
+
commodity_category_id: ration.commodity_category_id,
|
35
|
+
quantity: plan_days / ration.no_of_days * ration.quantity * rounds,
|
36
|
+
unit_id: ration.unit_of_measure_id,
|
37
|
+
received: false
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
RoundBeneficiary.insert_all!(round_beneficiaries, record_timestamps: true)
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def remove_items(plan_id, ids)
|
49
|
+
raise(StandardError, 'No beneficiaries specified.') if ids.count.zero?
|
50
|
+
|
51
|
+
begin
|
52
|
+
plan = RoundPlan.find(plan_id)
|
53
|
+
rescue ActiveRecord::RecordNotFound
|
54
|
+
raise(StandardError, 'Round plan not found.') unless plan
|
55
|
+
end
|
56
|
+
|
57
|
+
beneficiaries = RoundBeneficiary.joins(:round_plan_item)
|
58
|
+
.where(round_plan_item: { round_plan_id: plan_id })
|
59
|
+
to_delete = RoundBeneficiary.where(id: ids)
|
60
|
+
diff = to_delete - beneficiaries
|
61
|
+
raise(StandardError, 'Round plan beneficiaries should be from the same plan.') if diff.count.positive?
|
62
|
+
|
63
|
+
to_delete.delete_all
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
def confirm_receipt(plan_id, ids)
|
68
|
+
raise(StandardError, 'No beneficiaries specified.') if ids.count.zero?
|
69
|
+
|
70
|
+
begin
|
71
|
+
plan = RoundPlan.find(plan_id)
|
72
|
+
rescue ActiveRecord::RecordNotFound
|
73
|
+
raise(StandardError, 'Round plan not found.') unless plan
|
74
|
+
end
|
75
|
+
|
76
|
+
beneficiaries = RoundBeneficiary.joins(:round_plan_item)
|
77
|
+
.where(round_plan_item: { round_plan_id: plan_id })
|
78
|
+
to_confirm = RoundBeneficiary.where(id: ids)
|
79
|
+
diff = to_confirm - beneficiaries
|
80
|
+
raise(StandardError, 'Round plan beneficiaries should be from the same plan.') if diff.count.positive?
|
81
|
+
|
82
|
+
to_confirm.update_all(received: true)
|
83
|
+
true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -59,6 +59,85 @@ module Cats
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
# This method generates dispatch plan for a round plan by aggregating the FDP level
|
64
|
+
# quantities into woreda level quantity per commodity.
|
65
|
+
#
|
66
|
+
# Parameters:
|
67
|
+
# id => The ID of the round plan for which dispatch plan is to be generated
|
68
|
+
#
|
69
|
+
def generate(id)
|
70
|
+
details = RoundPlanItemDetail.joins(
|
71
|
+
beneficiary_round_plan_item: { round_plan_item: :round_plan }
|
72
|
+
).where(
|
73
|
+
beneficiary_round_plan_item: { cats_core_round_plan_items: { round_plan_id: id } }
|
74
|
+
).includes(
|
75
|
+
beneficiary_round_plan_item: {
|
76
|
+
round_plan_item: %i[round_plan region zone woreda fdp]
|
77
|
+
},
|
78
|
+
round_ration: :commodity_category
|
79
|
+
)
|
80
|
+
|
81
|
+
items = details.each_with_object([]) do |detail, res|
|
82
|
+
res << {
|
83
|
+
reference_no: nil,
|
84
|
+
region: detail.beneficiary_round_plan_item.round_plan_item.region.name,
|
85
|
+
zone: detail.beneficiary_round_plan_item.round_plan_item.zone.name,
|
86
|
+
woreda: detail.beneficiary_round_plan_item.round_plan_item.woreda.name,
|
87
|
+
fdp: detail.beneficiary_round_plan_item.round_plan_item.fdp.name,
|
88
|
+
commodity_category: detail.round_ration.commodity_category.name,
|
89
|
+
unit_id: detail.round_ration.unit_of_measure_id,
|
90
|
+
unit: detail.round_ration.unit_of_measure.abbreviation,
|
91
|
+
quantity: detail.quantity,
|
92
|
+
source_id: nil,
|
93
|
+
destination_id: detail.beneficiary_round_plan_item.round_plan_item.fdp.id,
|
94
|
+
commodity_id: nil,
|
95
|
+
commodity_status: Cats::Core::Commodity::GOOD
|
96
|
+
}
|
97
|
+
end
|
98
|
+
{
|
99
|
+
reference_no: nil,
|
100
|
+
dispatchable_id: id,
|
101
|
+
dispatchable_type: 'Cats::Core::RoundPlan',
|
102
|
+
items: items
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
# This method creates dispatch and dispatch plan items once
|
107
|
+
# users fill out additional details such as source and destination
|
108
|
+
# for generated dispatch plan items.
|
109
|
+
#
|
110
|
+
# NOTE: Users still have to go through each plan item and set the
|
111
|
+
# reference_no. If the product team comes up with a reference_no
|
112
|
+
# generation scheme, then we may use that to avoid this.
|
113
|
+
#
|
114
|
+
def bulk_create(payload, user)
|
115
|
+
plan = Cats::Core::DispatchPlan.new(
|
116
|
+
reference_no: payload[:reference_no],
|
117
|
+
dispatchable_id: payload[:dispatchable_id],
|
118
|
+
dispatchable_type: payload[:dispatchable_type],
|
119
|
+
prepared_by: user
|
120
|
+
)
|
121
|
+
ActiveRecord::Base.transaction do
|
122
|
+
plan.save!
|
123
|
+
|
124
|
+
items = payload[:items].each_with_object([]) do |item, res|
|
125
|
+
res << {
|
126
|
+
reference_no: item[:reference_no],
|
127
|
+
source_id: item[:source_id],
|
128
|
+
destination_id: item[:destination_id],
|
129
|
+
dispatch_plan_id: plan.id,
|
130
|
+
quantity: item[:quantity],
|
131
|
+
unit_id: item[:unit_id],
|
132
|
+
commodity_id: item[:commodity_id],
|
133
|
+
commodity_status: item[:commodity_status],
|
134
|
+
status: Cats::Core::DispatchPlanItem::UNAUTHORIZED
|
135
|
+
}
|
136
|
+
end
|
137
|
+
Cats::Core::DispatchPlanItem.insert_all(items, record_timestamps: true)
|
138
|
+
end
|
139
|
+
plan
|
140
|
+
end
|
62
141
|
end
|
63
142
|
end
|
64
143
|
end
|
data/config/routes.rb
CHANGED
@@ -84,7 +84,18 @@ Cats::Core::Engine.routes.draw do
|
|
84
84
|
post '/routes/bulk_create', controller: :routes, action: :bulk_create
|
85
85
|
resources :routes, except: %i[destroy]
|
86
86
|
|
87
|
+
resources :commodity_donations, except: %i[destroy]
|
88
|
+
resources :purchase_orders, except: %i[index destroy]
|
89
|
+
resources :cash_donations, except: %i[destroy] do
|
90
|
+
member do
|
91
|
+
get 'purchase_orders', controller: :purchase_orders, action: :index
|
92
|
+
end
|
93
|
+
end
|
94
|
+
resources :swaps, except: %i[destory]
|
95
|
+
resources :loans, except: %i[destory]
|
96
|
+
|
87
97
|
post '/dispatch_plans/filter', controller: :dispatch_plans, action: :filter
|
98
|
+
post '/dispatch_plans/bulk_create'
|
88
99
|
resources :dispatch_plans do
|
89
100
|
member do
|
90
101
|
get 'items', controller: :dispatch_plan_items, action: :index
|
@@ -160,13 +171,21 @@ Cats::Core::Engine.routes.draw do
|
|
160
171
|
resources :receipt_transactions, except: %i[index new edit destroy]
|
161
172
|
resources :lost_commodities, except: %i[index destroy]
|
162
173
|
get '/plans/:id/round_plans', controller: :round_plans, action: :index, as: :round_plans_plan
|
174
|
+
|
175
|
+
post '/round_beneficiaries/filter'
|
176
|
+
resources :round_beneficiaries, only: %i[show]
|
163
177
|
post '/round_plans/generate'
|
164
178
|
post '/round_plans/filter'
|
165
179
|
resources :round_plans, except: %i[index destroy] do
|
166
180
|
member do
|
181
|
+
post 'generate_dispatch_plan', controller: :dispatch_plans, action: :generate
|
167
182
|
post 'remove_items'
|
183
|
+
post 'remove_beneficiaries', controller: :round_beneficiaries, action: :remove_beneficiaries
|
184
|
+
post 'confirm_receipt', controller: :round_beneficiaries, action: :confirm_receipt
|
168
185
|
post 'generate_round_needs'
|
169
186
|
post 'approve'
|
187
|
+
post 'generate_distribution_list', controller: :round_beneficiaries, action: :generate
|
188
|
+
get 'beneficiaries', controller: :round_beneficiaries, action: :index
|
170
189
|
end
|
171
190
|
end
|
172
191
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateCatsCoreCommodityDonations < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodity_donations do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
6
|
+
t.string :shipping_reference
|
7
|
+
t.date :donated_on, null: false
|
8
|
+
t.references :donor,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'donor_on_cd_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_donors }
|
12
|
+
t.references :commodity_category,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'cc_on_cd_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
16
|
+
t.references :plan,
|
17
|
+
null: true,
|
18
|
+
index: { name: 'plan_on_cd_indx' },
|
19
|
+
foreign_key: { to_table: :cats_core_plans }
|
20
|
+
t.float :quantity, null: false
|
21
|
+
t.references :unit,
|
22
|
+
null: false,
|
23
|
+
index: { name: 'unit_on_cd_indx' },
|
24
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
25
|
+
|
26
|
+
t.timestamps
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateCatsCoreCashDonations < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_cash_donations do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
6
|
+
t.date :donated_on, null: false
|
7
|
+
t.references :donor,
|
8
|
+
null: false,
|
9
|
+
index: { name: 'donor_on_cad_indx' },
|
10
|
+
foreign_key: { to_table: :cats_core_donors }
|
11
|
+
t.float :amount, null: false
|
12
|
+
t.references :currency,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'currency_on_cad_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_currencies }
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,12 +3,6 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
|
|
3
3
|
create_table :cats_core_gift_certificates do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
5
|
t.date :gift_date, null: false
|
6
|
-
|
7
|
-
t.references :donation,
|
8
|
-
null: true,
|
9
|
-
index: { name: 'gc_on_donation_indx' },
|
10
|
-
foreign_key: { to_table: :cats_core_donations }
|
11
|
-
|
12
6
|
t.string :vessel
|
13
7
|
t.string :port
|
14
8
|
t.string :customs_declaration_no
|
@@ -20,9 +14,9 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
|
|
20
14
|
null: false,
|
21
15
|
index: { name: 'gc_on_cc_indx' },
|
22
16
|
foreign_key: { to_table: :cats_core_commodity_categories }
|
23
|
-
t.references :
|
17
|
+
t.references :unit,
|
24
18
|
null: false,
|
25
|
-
index: { name: '
|
19
|
+
index: { name: 'unit_on_gc_indx' },
|
26
20
|
foreign_key: { to_table: :cats_core_unit_of_measures }
|
27
21
|
t.references :destination_warehouse,
|
28
22
|
null: false,
|
@@ -7,14 +7,18 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1]
|
|
7
7
|
t.string :supplier, null: false
|
8
8
|
t.float :quantity, null: false
|
9
9
|
t.string :purchase_type, null: false
|
10
|
-
|
11
|
-
t.references :
|
10
|
+
t.float :price, null: false
|
11
|
+
t.references :currency,
|
12
|
+
null: false,
|
13
|
+
index: { name: 'currency_on_po_indx' },
|
14
|
+
foreign_key: { to_table: :cats_core_currencies }
|
15
|
+
t.references :cash_donation,
|
12
16
|
null: false,
|
13
|
-
index: { name: '
|
14
|
-
foreign_key: { to_table: :
|
17
|
+
index: { name: 'cd_on_po_indx' },
|
18
|
+
foreign_key: { to_table: :cats_core_cash_donations }
|
15
19
|
t.references :commodity_category,
|
16
20
|
null: false,
|
17
|
-
index: { name: '
|
21
|
+
index: { name: 'cc_on_po_indx' },
|
18
22
|
foreign_key: { to_table: :cats_core_commodity_categories }
|
19
23
|
t.references :unit,
|
20
24
|
null: false,
|
@@ -9,6 +9,10 @@ class CreateCatsCoreBeneficiaries < ActiveRecord::Migration[7.0]
|
|
9
9
|
null: false,
|
10
10
|
index: { name: 'bc_on_beneficiaries_indx' },
|
11
11
|
foreign_key: { to_table: :cats_core_beneficiary_categories }
|
12
|
+
t.references :fdp,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'fdp_on_beneficiaries_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_locations }
|
12
16
|
|
13
17
|
t.timestamps
|
14
18
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateCatsCoreLoans < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_loans do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :lender, null: false
|
6
|
+
t.date :agreement_date, null: false
|
7
|
+
t.date :repayment_date
|
8
|
+
t.references :commodity_category,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'cc_on_loan_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
12
|
+
t.float :quantity, null: false
|
13
|
+
t.references :unit,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'unit_on_loan_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateCatsCoreSwaps < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_swaps do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :swapper, null: false
|
6
|
+
t.date :agreement_date, null: false
|
7
|
+
t.float :issued_quantity, null: false
|
8
|
+
t.float :received_quantity, null: false
|
9
|
+
t.references :issued_commodity,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'ic_on_swap_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
13
|
+
t.references :received_commodity,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'rc_on_swap_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
17
|
+
t.references :issued_unit,
|
18
|
+
null: false,
|
19
|
+
index: { name: 'iu_on_swap_indx' },
|
20
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
21
|
+
t.references :received_unit,
|
22
|
+
null: false,
|
23
|
+
index: { name: 'ru_on_swap_indx' },
|
24
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
25
|
+
|
26
|
+
t.timestamps
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateCatsCoreRoundBeneficiaries < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_round_beneficiaries do |t|
|
4
|
+
t.references :beneficiary,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'beneficiary_on_rb_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_beneficiaries }
|
8
|
+
t.references :round_plan_item,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'rpi_on_rb_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_round_plan_items }
|
12
|
+
t.references :commodity_category,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'cc_on_rb_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
16
|
+
t.float :quantity, null: false
|
17
|
+
t.references :unit,
|
18
|
+
null: false,
|
19
|
+
index: { name: 'unit_on_rb_indx' },
|
20
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
21
|
+
t.boolean :received, null: false, default: false
|
22
|
+
|
23
|
+
t.timestamps
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
-
factory :
|
2
|
+
factory :commodity_donation, class: 'Cats::Core::CommodityDonation' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
4
|
description { FFaker::Name.name }
|
5
|
-
donation_type { Cats::Core::Donation::KIND }
|
6
5
|
shipping_reference { FFaker::Name.name }
|
7
6
|
donated_on { Date.today }
|
8
7
|
donor
|
9
8
|
plan
|
10
|
-
|
11
|
-
currency { nil }
|
9
|
+
quantity { 100 }
|
12
10
|
commodity_category
|
13
|
-
unit_of_measure
|
14
|
-
active { false }
|
11
|
+
unit factory: :unit_of_measure
|
15
12
|
end
|
16
13
|
end
|
@@ -2,10 +2,6 @@ FactoryBot.define do
|
|
2
2
|
factory :gift_certificate, class: 'Cats::Core::GiftCertificate' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
4
|
gift_date { Date.today - 1.month }
|
5
|
-
donation
|
6
|
-
commodity_category { donation.commodity_category }
|
7
|
-
unit_of_measure
|
8
|
-
destination_warehouse factory: :warehouse
|
9
5
|
vessel { FFaker::Name.name }
|
10
6
|
port { FFaker::Name.name }
|
11
7
|
customs_declaration_no { FFaker::Name.name }
|
@@ -13,8 +9,11 @@ FactoryBot.define do
|
|
13
9
|
expiry_date { Date.today + 6.month }
|
14
10
|
bill_of_lading_no { FFaker::Name.name }
|
15
11
|
quantity { 1.5 }
|
16
|
-
|
17
|
-
|
12
|
+
commodity_category
|
13
|
+
unit factory: :unit_of_measure
|
14
|
+
destination_warehouse factory: :warehouse
|
15
|
+
estimated_price { 500 }
|
16
|
+
estimated_tax { 200 }
|
18
17
|
currency
|
19
18
|
registration_no { FFaker::Name.name }
|
20
19
|
requested_by { FFaker::Name.name }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :loan, class: 'Cats::Core::Loan' do
|
3
|
+
reference_no { FFaker::Name.name }
|
4
|
+
lender { FFaker::Name.name }
|
5
|
+
agreement_date { Date.today }
|
6
|
+
repayment_date { agreement_date.next_month }
|
7
|
+
commodity_category
|
8
|
+
quantity { 100 }
|
9
|
+
unit factory: :unit_of_measure
|
10
|
+
end
|
11
|
+
end
|
@@ -2,7 +2,7 @@ FactoryBot.define do
|
|
2
2
|
factory :project, class: 'Cats::Core::Project' do
|
3
3
|
code { FFaker::Name.name }
|
4
4
|
description { FFaker::Name.name }
|
5
|
-
source factory: :
|
5
|
+
source factory: :commodity_donation
|
6
6
|
program
|
7
7
|
year { 2022 }
|
8
8
|
implementing_agency { FFaker::Name.name }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :swap, class: 'Cats::Core::Swap' do
|
3
|
+
reference_no { FFaker::Name.name }
|
4
|
+
swapper { FFaker::Name.name }
|
5
|
+
agreement_date { Date.yesterday }
|
6
|
+
issued_commodity factory: :commodity_category
|
7
|
+
issued_quantity { 100 }
|
8
|
+
issued_unit factory: :unit_of_measure
|
9
|
+
received_commodity factory: :commodity_category
|
10
|
+
received_quantity { 150 }
|
11
|
+
received_unit factory: :unit_of_measure
|
12
|
+
end
|
13
|
+
end
|