dscf-marketplace 0.7.1 โ 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/db/seeds.rb +34 -339
- data/lib/dscf/marketplace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81c4fc2b3cbb08308f4da22f26a56d9d7a3ca197325c340d491dacfe4adbaa6f
|
|
4
|
+
data.tar.gz: 1c89213f1171138ea6efc0c8566a60a6937348c7c934cfacc8ccecd53f35c310
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f812ce7f37138fbf88cfed6c03233193b12fef8a194f8cd632c8006b86814201af5877122679c9634920bcb4ba73291e7ea2171009be15265a38cd9dad524c5
|
|
7
|
+
data.tar.gz: e6ffd5232a4f43d7d4020f789a0ce6b400858ffd2801192a7008dab0ffd4f66f3dcd3488c0364f26d8861c2b451eb2d6f1f2edcfbd9b990363cd121b6905a3b6
|
data/db/seeds.rb
CHANGED
|
@@ -1,343 +1,38 @@
|
|
|
1
|
-
puts "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Categories
|
|
27
|
-
fruits_veg = Dscf::Marketplace::Category.create!(name: "Fruits & Vegetables")
|
|
28
|
-
dairy = Dscf::Marketplace::Category.create!(name: "Dairy Products")
|
|
29
|
-
Dscf::Marketplace::Category.create!(name: "Grains & Cereals")
|
|
30
|
-
Dscf::Marketplace::Category.create!(name: "Beverages")
|
|
31
|
-
|
|
32
|
-
puts "โ
Created #{Dscf::Marketplace::Unit.count} units and #{Dscf::Marketplace::Category.count} categories"
|
|
33
|
-
|
|
34
|
-
puts "๐ฅ Creating users and personas..."
|
|
35
|
-
|
|
36
|
-
# Business Types
|
|
37
|
-
wholesale_type = Dscf::Core::BusinessType.find_or_create_by!(name: "Wholesale Distributor")
|
|
38
|
-
retail_type = Dscf::Core::BusinessType.find_or_create_by!(name: "Retail Store")
|
|
39
|
-
|
|
40
|
-
# Consumers
|
|
41
|
-
consumer1 = Dscf::Core::User.create!(
|
|
42
|
-
email: "abebe.consumer@example.com",
|
|
43
|
-
phone: "+251911123456"
|
|
44
|
-
)
|
|
45
|
-
consumer2 = Dscf::Core::User.create!(
|
|
46
|
-
email: "tigist.consumer@example.com",
|
|
47
|
-
phone: "+251922334567"
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
# Drivers
|
|
51
|
-
driver1 = Dscf::Core::User.create!(
|
|
52
|
-
email: "driver.ahmed@example.com",
|
|
53
|
-
phone: "+251933445678"
|
|
54
|
-
)
|
|
55
|
-
Dscf::Core::User.create!(
|
|
56
|
-
email: "driver.mariam@example.com",
|
|
57
|
-
phone: "+251944556789"
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
puts "โ
Created #{Dscf::Core::User.count} users (#{Dscf::Core::User.where("email LIKE ?", "%consumer%").count} consumers, #{Dscf::Core::User.where("email LIKE ?", "%driver%").count} drivers)"
|
|
61
|
-
|
|
62
|
-
puts "๐ข Creating businesses and linking to users..."
|
|
63
|
-
|
|
64
|
-
# Wholesalers
|
|
65
|
-
wholesale_user1 = Dscf::Core::User.create!(
|
|
66
|
-
email: "wholesale.addis@example.com",
|
|
67
|
-
phone: "+251955667890"
|
|
68
|
-
)
|
|
69
|
-
wholesaler1 = Dscf::Core::Business.create!(
|
|
70
|
-
name: "Addis Wholesale Distributors",
|
|
71
|
-
contact_email: "contact@addiswholesale.et",
|
|
72
|
-
contact_phone: "+251966778901",
|
|
73
|
-
tin_number: "1234567890",
|
|
74
|
-
business_type: wholesale_type,
|
|
75
|
-
user: wholesale_user1
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
wholesale_user2 = Dscf::Core::User.create!(
|
|
79
|
-
email: "wholesale.ethio@example.com",
|
|
80
|
-
phone: "+251977889012"
|
|
81
|
-
)
|
|
82
|
-
wholesaler2 = Dscf::Core::Business.create!(
|
|
83
|
-
name: "Ethio Agricultural Wholesale",
|
|
84
|
-
contact_email: "info@ethiowholesale.et",
|
|
85
|
-
contact_phone: "+251988990123",
|
|
86
|
-
tin_number: "0987654321",
|
|
87
|
-
business_type: wholesale_type,
|
|
88
|
-
user: wholesale_user2
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
# Retailers
|
|
92
|
-
retail_user1 = Dscf::Core::User.create!(
|
|
93
|
-
email: "retail.meklit@example.com",
|
|
94
|
-
phone: "+251999001234"
|
|
95
|
-
)
|
|
96
|
-
Dscf::Core::Business.create!(
|
|
97
|
-
name: "Meklit Fresh Market",
|
|
98
|
-
contact_email: "meklit@freshmarket.et",
|
|
99
|
-
contact_phone: "+251910112345",
|
|
100
|
-
tin_number: "1122334455",
|
|
101
|
-
business_type: retail_type,
|
|
102
|
-
user: retail_user1
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
retail_user2 = Dscf::Core::User.create!(
|
|
106
|
-
email: "retail.bole@example.com",
|
|
107
|
-
phone: "+251921223456"
|
|
108
|
-
)
|
|
109
|
-
Dscf::Core::Business.create!(
|
|
110
|
-
name: "Bole Modern Supermarket",
|
|
111
|
-
contact_email: "info@bolesuper.et",
|
|
112
|
-
contact_phone: "+251932334567",
|
|
113
|
-
tin_number: "5566778899",
|
|
114
|
-
business_type: retail_type,
|
|
115
|
-
user: retail_user2
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
puts "โ
Created #{Dscf::Core::Business.count} businesses (#{Dscf::Core::Business.joins(:user).where("dscf_core_users.email LIKE ?", "%wholesale%").count} wholesalers, #{Dscf::Core::Business.joins(:user).where("dscf_core_users.email LIKE ?", "%retail%").count} retailers)"
|
|
119
|
-
|
|
120
|
-
puts "๐ฆ Creating products and supplier listings..."
|
|
121
|
-
|
|
122
|
-
# Products from wholesalers
|
|
123
|
-
banana_product = wholesaler1.supplier_products.create!(
|
|
124
|
-
product: Dscf::Marketplace::Product.create!(
|
|
125
|
-
name: "Fresh Bananas",
|
|
126
|
-
category: fruits_veg,
|
|
127
|
-
unit: kg
|
|
128
|
-
)
|
|
129
|
-
)
|
|
130
|
-
banana_listing = Dscf::Marketplace::Listing.create!(
|
|
131
|
-
supplier_product: banana_product,
|
|
132
|
-
price: 25.00,
|
|
133
|
-
quantity: 1000,
|
|
134
|
-
status: :active
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
milk_product = wholesaler2.supplier_products.create!(
|
|
138
|
-
product: Dscf::Marketplace::Product.create!(
|
|
139
|
-
name: "Fresh Cow Milk",
|
|
140
|
-
category: dairy,
|
|
141
|
-
unit: liter
|
|
142
|
-
)
|
|
143
|
-
)
|
|
144
|
-
milk_listing = Dscf::Marketplace::Listing.create!(
|
|
145
|
-
supplier_product: milk_product,
|
|
146
|
-
price: 45.00,
|
|
147
|
-
quantity: 500,
|
|
148
|
-
status: :active
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
puts "โ
Created #{Dscf::Marketplace::Product.count} products and #{Dscf::Marketplace::Listing.count} active listings"
|
|
152
|
-
|
|
153
|
-
puts "๐ Creating RFQs and quotations..."
|
|
154
|
-
|
|
155
|
-
# RFQ from retailer to wholesalers
|
|
156
|
-
rfq = Dscf::Marketplace::RequestForQuotation.create!(
|
|
157
|
-
user: retail_user1,
|
|
158
|
-
status: :sent,
|
|
159
|
-
notes: "Monthly supply of fresh produce"
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
# RFQ items
|
|
163
|
-
rfq.rfq_items.create!(
|
|
164
|
-
product: banana_product.product,
|
|
165
|
-
unit: kg,
|
|
166
|
-
quantity: 200,
|
|
167
|
-
notes: "Premium quality bananas"
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
rfq.rfq_items.create!(
|
|
171
|
-
product: milk_product.product,
|
|
172
|
-
unit: liter,
|
|
173
|
-
quantity: 100,
|
|
174
|
-
notes: "Fresh morning milk"
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
# Quotations from wholesalers
|
|
178
|
-
quotation1 = Dscf::Marketplace::Quotation.create!(
|
|
179
|
-
request_for_quotation: rfq,
|
|
180
|
-
business: wholesaler1,
|
|
181
|
-
total_price: 5000.00,
|
|
182
|
-
delivery_date: 3.days.from_now.to_date,
|
|
183
|
-
valid_until: 10.days.from_now,
|
|
184
|
-
status: :accepted,
|
|
185
|
-
notes: "Competitive pricing for bulk orders"
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
quotation1.quotation_items.create!(
|
|
189
|
-
rfq_item: rfq.rfq_items.first,
|
|
190
|
-
product: banana_product.product,
|
|
191
|
-
unit: kg,
|
|
192
|
-
quantity: 200,
|
|
193
|
-
unit_price: 25.00
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
quotation2 = Dscf::Marketplace::Quotation.create!(
|
|
197
|
-
request_for_quotation: rfq,
|
|
198
|
-
business: wholesaler2,
|
|
199
|
-
total_price: 4500.00,
|
|
200
|
-
delivery_date: 2.days.from_now.to_date,
|
|
201
|
-
valid_until: 8.days.from_now,
|
|
202
|
-
status: :sent,
|
|
203
|
-
notes: "Direct from farm fresh milk"
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
quotation2.quotation_items.create!(
|
|
207
|
-
rfq_item: rfq.rfq_items.second,
|
|
208
|
-
product: milk_product.product,
|
|
209
|
-
unit: liter,
|
|
210
|
-
quantity: 100,
|
|
211
|
-
unit_price: 45.00
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
puts "โ
Created #{Dscf::Marketplace::RequestForQuotation.count} RFQs with #{Dscf::Marketplace::Quotation.count} quotations"
|
|
215
|
-
|
|
216
|
-
puts "๐ Creating orders from consumers and retailers..."
|
|
217
|
-
|
|
218
|
-
# Addresses for orders
|
|
219
|
-
consumer_address = Dscf::Core::Address.create!(
|
|
220
|
-
user: consumer1,
|
|
221
|
-
address_type: :shipping,
|
|
222
|
-
country: "Ethiopia",
|
|
223
|
-
city: "Addis Ababa",
|
|
224
|
-
sub_city: "Bole",
|
|
225
|
-
woreda: "05",
|
|
226
|
-
kebele: "09",
|
|
227
|
-
house_numbers: "123",
|
|
228
|
-
po_box: "5678",
|
|
229
|
-
latitude: 9.0108,
|
|
230
|
-
longitude: 38.7613
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
retailer_address = Dscf::Core::Address.create!(
|
|
234
|
-
user: retail_user1,
|
|
235
|
-
address_type: :shipping,
|
|
236
|
-
country: "Ethiopia",
|
|
237
|
-
city: "Addis Ababa",
|
|
238
|
-
sub_city: "Piassa",
|
|
239
|
-
woreda: "01",
|
|
240
|
-
kebele: "12",
|
|
241
|
-
house_numbers: "456",
|
|
242
|
-
po_box: "9012",
|
|
243
|
-
latitude: 9.0308,
|
|
244
|
-
longitude: 38.7413
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
# Order from consumer via direct listing
|
|
248
|
-
consumer_order = Dscf::Marketplace::Order.create_from_listing(
|
|
249
|
-
milk_listing,
|
|
250
|
-
consumer1,
|
|
251
|
-
10,
|
|
252
|
-
consumer_address
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
# Order from retailer via accepted quotation
|
|
256
|
-
retailer_order = Dscf::Marketplace::Order.create_from_quotation(
|
|
257
|
-
quotation1,
|
|
258
|
-
retailer_address
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
puts "โ
Created #{Dscf::Marketplace::Order.count} orders (#{Dscf::Marketplace::Order.where(order_type: :direct_listing).count} direct, #{Dscf::Marketplace::Order.where(order_type: :rfq_based).count} RFQ-based)"
|
|
262
|
-
|
|
263
|
-
puts "๐ Creating delivery orders with multiple dropoffs..."
|
|
264
|
-
|
|
265
|
-
# Pickup address
|
|
266
|
-
pickup_address = Dscf::Core::Address.create!(
|
|
267
|
-
user: wholesaler1.user,
|
|
268
|
-
address_type: :business,
|
|
269
|
-
country: "Ethiopia",
|
|
270
|
-
city: "Addis Ababa",
|
|
271
|
-
sub_city: "Kazanchis",
|
|
272
|
-
woreda: "03",
|
|
273
|
-
kebele: "15",
|
|
274
|
-
house_numbers: "789",
|
|
275
|
-
po_box: "3456",
|
|
276
|
-
latitude: 9.0208,
|
|
277
|
-
longitude: 38.7513
|
|
278
|
-
)
|
|
279
|
-
|
|
280
|
-
# Additional dropoff
|
|
281
|
-
extra_address = Dscf::Core::Address.create!(
|
|
282
|
-
user: consumer2,
|
|
283
|
-
address_type: :shipping,
|
|
284
|
-
country: "Ethiopia",
|
|
285
|
-
city: "Addis Ababa",
|
|
286
|
-
sub_city: "Merkato",
|
|
287
|
-
woreda: "07",
|
|
288
|
-
kebele: "21",
|
|
289
|
-
house_numbers: "101",
|
|
290
|
-
po_box: "7890",
|
|
291
|
-
latitude: 9.0008,
|
|
292
|
-
longitude: 38.7713
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
# Create delivery order
|
|
296
|
-
delivery_order = Dscf::Marketplace::DeliveryOrder.create!(
|
|
297
|
-
driver: driver1,
|
|
298
|
-
pickup_address: pickup_address,
|
|
299
|
-
status: :assigned,
|
|
300
|
-
vehicle_type: :motorcycle,
|
|
301
|
-
estimated_delivery_price: 150.00,
|
|
302
|
-
estimated_delivery_time: 2.hours.from_now
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
# Associate orders
|
|
306
|
-
consumer_order.update!(delivery_order: delivery_order)
|
|
307
|
-
retailer_order.update!(delivery_order: delivery_order)
|
|
308
|
-
|
|
309
|
-
# Create additional order for third dropoff
|
|
310
|
-
extra_order = Dscf::Marketplace::Order.create_from_listing(
|
|
311
|
-
banana_listing,
|
|
312
|
-
consumer2,
|
|
313
|
-
5,
|
|
314
|
-
extra_address
|
|
315
|
-
)
|
|
316
|
-
extra_order.update!(delivery_order: delivery_order)
|
|
317
|
-
|
|
318
|
-
# Create delivery order items
|
|
319
|
-
delivery_order.delivery_order_items.create!(
|
|
320
|
-
order_item: consumer_order.order_items.first,
|
|
321
|
-
pickup_address: pickup_address,
|
|
322
|
-
dropoff_address: consumer_address
|
|
323
|
-
)
|
|
1
|
+
puts "๐ฑ Seeding marketplace permissions and default USER role..."
|
|
2
|
+
|
|
3
|
+
Dscf::Core::PermissionRegistry.register("dscf-marketplace") do
|
|
4
|
+
resource :categories, actions: %i[index show create update destroy subcategories]
|
|
5
|
+
resource :products, actions: %i[index show create update destroy filter supplier_products]
|
|
6
|
+
resource :units, actions: %i[index show create update destroy]
|
|
7
|
+
resource :unit_conversions, actions: %i[index show create update destroy]
|
|
8
|
+
resource :supplier_products, actions: %i[index show create update destroy my_products]
|
|
9
|
+
resource :listings, actions: %i[index show create update destroy activate pause sold_out my_listings listings_by_supplier]
|
|
10
|
+
resource :request_for_quotations, actions: %i[index show create update destroy send_rfq close respond my_rfqs filter]
|
|
11
|
+
resource :rfq_items, actions: %i[index show create update destroy]
|
|
12
|
+
resource :quotations, actions: %i[index show create update destroy accept reject send_quotation my_quotes filter]
|
|
13
|
+
resource :quotation_items, actions: %i[index show create update destroy]
|
|
14
|
+
resource :orders, actions: %i[index show create update destroy confirm cancel complete my_orders filter]
|
|
15
|
+
resource :order_items, actions: %i[index show create update destroy]
|
|
16
|
+
resource :delivery_orders, actions: %i[
|
|
17
|
+
index show create update destroy pickup start_delivery complete_delivery mark_failed accept summary
|
|
18
|
+
my_driver_deliveries filter convert_orders
|
|
19
|
+
]
|
|
20
|
+
resource :delivery_stops, actions: %i[index show create update destroy verify]
|
|
21
|
+
resource :delivery_order_items, actions: %i[index show create update destroy receiver_confirm report_issue dispute_delivery]
|
|
22
|
+
resource :delivery_vehicles, actions: %i[index show create update destroy]
|
|
23
|
+
resource :locations, actions: %i[get_location]
|
|
24
|
+
end
|
|
324
25
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
26
|
+
user_role = Dscf::Core::Role.find_or_create_by!(code: "USER") do |role|
|
|
27
|
+
role.name = "User"
|
|
28
|
+
role.active = true
|
|
29
|
+
end
|
|
30
|
+
user_role.update!(name: "User", active: true)
|
|
330
31
|
|
|
331
|
-
|
|
332
|
-
order_item: extra_order.order_items.first,
|
|
333
|
-
pickup_address: pickup_address,
|
|
334
|
-
dropoff_address: extra_address
|
|
335
|
-
)
|
|
32
|
+
marketplace_permissions = Dscf::Core::Permission.where(engine: "dscf-marketplace")
|
|
336
33
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
rescue => e
|
|
340
|
-
puts "โ Seed failed: #{e.message}"
|
|
341
|
-
puts e.backtrace
|
|
342
|
-
raise
|
|
34
|
+
marketplace_permissions.find_each do |permission|
|
|
35
|
+
Dscf::Core::RolePermission.find_or_create_by!(role: user_role, permission: permission)
|
|
343
36
|
end
|
|
37
|
+
|
|
38
|
+
puts "โ
Seeded #{marketplace_permissions.count} marketplace permissions and assigned to USER role."
|