dscf-marketplace 0.9.4 → 0.9.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3344e182285e4e49140063b5e39456c4c51f9485460da13ec7e5a6e948fc0b3c
4
- data.tar.gz: 9abdca4e70f5c315fa000ca5950d9dfc503dae85a167b3cef087e7c511757ccd
3
+ metadata.gz: a0e91f63e7ff64555d501536f0a77dbf3942fd4ad5a72f9e546306141c1d5901
4
+ data.tar.gz: 7b3826928b8f65fdaee4e448657b69bcf2e8eec33ec1c00498c679d52437b410
5
5
  SHA512:
6
- metadata.gz: '09781023abf0128615ddd44b516240f2fe32d83b582fb072fd4f86c40ea329e991b2dccfa0221512db413ba189b5955f0762f745bcf03adcab5c2d15a01cb2cd'
7
- data.tar.gz: ed58b55872828a27773e9f72852f3ee301beb896b7b44df8fd841a2dd7b61d7d1e1ed56fc32e7fd2108f43526b854f12115ad57a0d3765f4a1cee3028945f5b1
6
+ metadata.gz: 37ac177b888c28335a60d18ca44485a4748ea1f71b58850a85dc6a465e68873776fa61a87b63b21b4680c501266181de4d743211dc88009fb4cf88155f2e6c6c
7
+ data.tar.gz: b42feafb45858e7f9d5e91826f32ea88469aeb2e7e55b9c8644f8dc7fc5d08f499f977b48ec2bfd9553665171d3f9a8b54878e6696946e8d452fa655f1baa9fb
@@ -32,8 +32,7 @@ module Dscf
32
32
 
33
33
  def self.supplier_confirm(order, confirmed: true, reason: nil)
34
34
  if confirmed
35
- # In full impl, mark specific allocation as confirmed
36
- # For now advance whole if appropriate
35
+ order.order_items.where(status: :processing).update_all(status: OrderItem.statuses[:confirmed])
37
36
  else
38
37
  order.order_items.where(status: :processing).update_all(status: OrderItem.statuses[:cancelled])
39
38
  end
@@ -52,7 +52,7 @@ module Dscf
52
52
  # Fallback: find cheapest active listing for the product
53
53
  Listing.active
54
54
  .joins(:supplier_product)
55
- .where(supplier_products: {product_id: item.product_id})
55
+ .where(dscf_marketplace_supplier_products: {product_id: item.product_id})
56
56
  .order(price: :asc)
57
57
  .first
58
58
  end
@@ -0,0 +1,274 @@
1
+ # ════════════════════════════════════════════════════════════════════════════
2
+ # ANTIGRAVITY SEEDS — Clean, collision-free, and fully idempotent demo data
3
+ # ════════════════════════════════════════════════════════════════════════════
4
+ # NOTE: This script does NOT delete any existing tables or database records.
5
+ # It safely finds-or-creates our custom test ecosystem.
6
+
7
+ puts "🌱 Initializing Antigravity test data safely..."
8
+
9
+ # ── 1. Find Existing Super Admin ──
10
+ admin = Dscf::Core::User.find_by(email: "admin@dscf.com")
11
+ unless admin
12
+ puts "❌ admin@dscf.com not found! Creating default admin as fallback..."
13
+ admin = Dscf::Core::User.create!(
14
+ email: "admin@dscf.com",
15
+ phone: "+251999000000",
16
+ password: "Admin@2024",
17
+ verified_at: Time.current,
18
+ temp_password: false
19
+ )
20
+ end
21
+
22
+ sa_role = Dscf::Core::Role.find_or_create_by!(code: "SUPER_ADMIN") { |r| r.name = "Super Admin"; r.active = true }
23
+ Dscf::Core::UserRole.find_or_create_by!(user: admin, role: sa_role)
24
+
25
+ # Ensure SUPER_ADMIN has basic orders permissions
26
+ orders_perms = Dscf::Core::Permission.where(resource: "orders")
27
+ orders_perms.each do |perm|
28
+ Dscf::Core::RolePermission.find_or_create_by!(role: sa_role, permission: perm)
29
+ end
30
+ puts "✅ Super Admin configured."
31
+
32
+ # ── 2. Find or Create Custom Antigravity Users safely ──
33
+ retailer_user = Dscf::Core::User.find_by(email: "antigravity.retailer@example.com")
34
+ unless retailer_user
35
+ phone = "+251977111111"
36
+ # Avoid phone collisions if already taken
37
+ while Dscf::Core::User.exists?(phone: phone)
38
+ phone = "+251977111#{rand(100..999)}"
39
+ end
40
+
41
+ retailer_user = Dscf::Core::User.create!(
42
+ email: "antigravity.retailer@example.com",
43
+ phone: phone,
44
+ password: "password",
45
+ verified_at: Time.current,
46
+ temp_password: false
47
+ )
48
+ end
49
+
50
+ supplier_user = Dscf::Core::User.find_by(email: "antigravity.supplier@example.com")
51
+ unless supplier_user
52
+ phone = "+251977222222"
53
+ # Avoid phone collisions if already taken
54
+ while Dscf::Core::User.exists?(phone: phone)
55
+ phone = "+251977222#{rand(100..999)}"
56
+ end
57
+
58
+ supplier_user = Dscf::Core::User.create!(
59
+ email: "antigravity.supplier@example.com",
60
+ phone: phone,
61
+ password: "password",
62
+ verified_at: Time.current,
63
+ temp_password: false
64
+ )
65
+ end
66
+
67
+ # Assign default USER role
68
+ user_role = Dscf::Core::Role.find_or_create_by!(code: "USER") { |r| r.name = "User"; r.active = true }
69
+ Dscf::Core::UserRole.find_or_create_by!(user: retailer_user, role: user_role)
70
+ Dscf::Core::UserRole.find_or_create_by!(user: supplier_user, role: user_role)
71
+
72
+ # Assign marketplace permissions to USER role
73
+ Dscf::Core::Permission.where(engine: "dscf-marketplace").find_each do |perm|
74
+ Dscf::Core::RolePermission.find_or_create_by!(role: user_role, permission: perm)
75
+ end
76
+
77
+ puts "✅ Custom users verified/created."
78
+
79
+ # ── 3. Find or Create Custom Businesses safely ──
80
+ bt_manufacturer = Dscf::Core::BusinessType.find_or_create_by!(name: "Manufacturer")
81
+ bt_retailer = Dscf::Core::BusinessType.find_or_create_by!(name: "Retailer")
82
+
83
+ retailer_biz = Dscf::Core::Business.find_by(tin_number: "TIN-AG-RET-001")
84
+ unless retailer_biz
85
+ phone = "+251977111112"
86
+ while Dscf::Core::Business.exists?(contact_phone: phone)
87
+ phone = "+251977111#{rand(100..999)}"
88
+ end
89
+
90
+ retailer_biz = Dscf::Core::Business.create!(
91
+ name: "Antigravity Supermarket",
92
+ user: retailer_user,
93
+ business_type: bt_retailer,
94
+ contact_phone: phone,
95
+ description: "Antigravity Premium Retailer Store",
96
+ tin_number: "TIN-AG-RET-001"
97
+ )
98
+ end
99
+
100
+ supplier_biz = Dscf::Core::Business.find_by(tin_number: "TIN-AG-SUP-001")
101
+ unless supplier_biz
102
+ phone = "+251977222223"
103
+ while Dscf::Core::Business.exists?(contact_phone: phone)
104
+ phone = "+251977222#{rand(100..999)}"
105
+ end
106
+
107
+ supplier_biz = Dscf::Core::Business.create!(
108
+ name: "Antigravity Coffee & Textile Wholesaler",
109
+ user: supplier_user,
110
+ business_type: bt_manufacturer,
111
+ contact_phone: phone,
112
+ description: "Premium Antigravity Wholesaler Export",
113
+ tin_number: "TIN-AG-SUP-001"
114
+ )
115
+ end
116
+
117
+ aggregator_biz = Dscf::Core::Business.find_by(tin_number: "TIN-AG-AGG-001")
118
+ unless aggregator_biz
119
+ phone = "+251977333333"
120
+ while Dscf::Core::Business.exists?(contact_phone: phone)
121
+ phone = "+251977333#{rand(100..999)}"
122
+ end
123
+
124
+ aggregator_biz = Dscf::Core::Business.create!(
125
+ name: "Antigravity Aggregators",
126
+ user: admin,
127
+ business_type: bt_manufacturer,
128
+ contact_phone: phone,
129
+ description: "Official Antigravity Marketplace Aggregator Hub",
130
+ tin_number: "TIN-AG-AGG-001"
131
+ )
132
+ end
133
+
134
+ puts "✅ Custom businesses verified/created."
135
+
136
+ # ── 4. Categories & Units ──
137
+ cat_coffee = Dscf::Marketplace::Category.find_or_create_by!(name: "Antigravity Coffee") do |c|
138
+ c.description = "Specialty roasted Ethiopian coffee"
139
+ end
140
+
141
+ cat_textile = Dscf::Marketplace::Category.find_or_create_by!(name: "Antigravity Textiles") do |c|
142
+ c.description = "Premium handwoven fabrics"
143
+ end
144
+
145
+ u_kg = Dscf::Marketplace::Unit.find_or_create_by!(code: "KG") do |u|
146
+ u.name = "Kilogram"
147
+ u.unit_type = :weight
148
+ end
149
+
150
+ u_meter = Dscf::Marketplace::Unit.find_or_create_by!(code: "M") do |u|
151
+ u.name = "Meter"
152
+ u.unit_type = :dimension
153
+ end
154
+
155
+ puts "✅ Categories & Units verified/created."
156
+
157
+ # ── 5. Products ──
158
+ p1 = Dscf::Marketplace::Product.find_or_create_by!(sku: "AG-COF-SID") do |p|
159
+ p.name = "Antigravity Sidamo Roasted Coffee"
160
+ p.description = "Premium washed Sidamo — Medium Roast"
161
+ p.category = cat_coffee
162
+ p.unit = u_kg
163
+ p.base_quantity = 1.0
164
+ p.gross_weight = 1.2
165
+ end
166
+
167
+ p2 = Dscf::Marketplace::Product.find_or_create_by!(sku: "AG-TEX-GAB") do |p|
168
+ p.name = "Antigravity Traditional Gabi Fabric"
169
+ p.description = "Handwoven thick cotton Gabi"
170
+ p.category = cat_textile
171
+ p.unit = u_meter
172
+ p.base_quantity = 1.0
173
+ p.gross_weight = 0.8
174
+ end
175
+
176
+ puts "✅ Products verified/created."
177
+
178
+ # ── 6. Supplier Record ──
179
+ supplier_record = Dscf::Marketplace::Supplier.find_or_create_by!(business_id: supplier_biz.id) do |s|
180
+ s.name = "Antigravity Wholesaler Outlet"
181
+ s.business_type = :manufacturer
182
+ s.contact_phone = supplier_biz.contact_phone
183
+ s.address = "Bole Sub-city, Addis Ababa"
184
+ end
185
+
186
+ # ── 7. Supplier Products ──
187
+ sp1 = Dscf::Marketplace::SupplierProduct.find_or_create_by!(business_id: supplier_biz.id, product_id: p1.id) do |sp|
188
+ sp.supplier = supplier_record
189
+ sp.supplier_price = 400
190
+ sp.available_quantity = 1000
191
+ sp.minimum_order_quantity = 5
192
+ sp.status = :active
193
+ end
194
+
195
+ sp2 = Dscf::Marketplace::SupplierProduct.find_or_create_by!(business_id: supplier_biz.id, product_id: p2.id) do |sp|
196
+ sp.supplier = supplier_record
197
+ sp.supplier_price = 300
198
+ sp.available_quantity = 500
199
+ sp.minimum_order_quantity = 2
200
+ sp.status = :active
201
+ end
202
+
203
+ puts "✅ Supplier Products verified/created."
204
+
205
+ # ── 8. Aggregator Listings (Sprint 2 Core Target) ──
206
+ al1 = Dscf::Marketplace::AggregatorListing.find_or_create_by!(aggregator_id: aggregator_biz.id, supplier_product_id: sp1.id) do |al|
207
+ al.price = 550
208
+ al.quantity = 200
209
+ al.status = 0 # active/published
210
+ end
211
+
212
+ al2 = Dscf::Marketplace::AggregatorListing.find_or_create_by!(aggregator_id: aggregator_biz.id, supplier_product_id: sp2.id) do |al|
213
+ al.price = 420
214
+ al.quantity = 150
215
+ al.status = 0 # active/published
216
+ end
217
+
218
+ puts "✅ Aggregator Listings verified/created."
219
+
220
+ # ── 9. Direct Listings ──
221
+ Dscf::Marketplace::Listing.find_or_create_by!(business_id: supplier_biz.id, supplier_product_id: sp1.id) do |l|
222
+ l.price = 500
223
+ l.quantity = 300
224
+ l.status = :active
225
+ l.description = "Direct Sidamo Roasted Coffee from Antigravity Outlet"
226
+ end
227
+
228
+ Dscf::Marketplace::Listing.find_or_create_by!(business_id: supplier_biz.id, supplier_product_id: sp2.id) do |l|
229
+ l.price = 380
230
+ l.quantity = 200
231
+ l.status = :active
232
+ l.description = "Direct Traditional Handwoven Gabi from Antigravity Outlet"
233
+ end
234
+
235
+ puts "✅ Direct Listings verified/created."
236
+
237
+ # ── 10. Demo Addresses & Agents ──
238
+ address = Dscf::Core::Address.find_by(user_id: retailer_user.id)
239
+ unless address
240
+ address = Dscf::Core::Address.create!(
241
+ user: retailer_user,
242
+ address_type: :shipping,
243
+ country: "Ethiopia",
244
+ city: "Addis Ababa",
245
+ sub_city: "Bole Sub-city",
246
+ woreda: "Woreda 03",
247
+ house_numbers: "Suite 4B"
248
+ )
249
+ end
250
+
251
+ agent = Dscf::Marketplace::Agent.find_by(onboarded_by_id: aggregator_biz.id)
252
+ unless agent
253
+ agent_phone = "+251977444444"
254
+ while Dscf::Marketplace::Agent.exists?(phone: agent_phone)
255
+ agent_phone = "+251977444#{rand(100..999)}"
256
+ end
257
+
258
+ Dscf::Marketplace::Agent.create!(
259
+ name: "Antigravity Logistics Agent",
260
+ phone: agent_phone,
261
+ service_area: "Bole Sub-city",
262
+ status: :active,
263
+ verification_status: :verified,
264
+ onboarded_by: aggregator_biz
265
+ )
266
+ end
267
+
268
+ puts "🎉 ALL ANTIGRAVITY SEEDS COMPLETED SUCCESSFULLY WITHOUT DELETING ANY DATA."
269
+ puts "--------------------------------------------------------"
270
+ puts "🔑 CREDENTIALS TO USE:"
271
+ puts "Buyer (Retailer): antigravity.retailer@example.com / password"
272
+ puts "Supplier (Wholesaler): antigravity.supplier@example.com / password"
273
+ puts "Super Admin: admin@dscf.com / Admin@2024"
274
+ puts "--------------------------------------------------------"
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.9.4".freeze
3
+ VERSION = "0.9.5".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-marketplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-06-26 00:00:00.000000000 Z
10
+ date: 2026-06-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -533,6 +533,7 @@ files:
533
533
  - config/environments/production.rb
534
534
  - config/locales/en.yml
535
535
  - config/routes.rb
536
+ - db/antigravity_seeds.rb
536
537
  - db/demo_seeds.rb
537
538
  - db/migrate/20250827172043_create_dscf_marketplace_categories.rb
538
539
  - db/migrate/20250827173526_update_dscf_marketplace_categories_indexes.rb