dscf-marketplace 0.4.6 → 0.4.8

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: e3d34992026013336d09084b0e2679c7681013c06da1e81e226a17bfcf98c846
4
- data.tar.gz: d8576224a26ec0115c3721f2c924f021bf3f896987b0a55a4785b37c6be6a751
3
+ metadata.gz: c5da4085e2caadf1df71f943d67cece2c0c71321ba45e7238240e27cddbf8732
4
+ data.tar.gz: 295de7880f4419b2f9a427159f58fcea661cbac0421a8524196cfd18a91eba13
5
5
  SHA512:
6
- metadata.gz: bf9dcac6ea2394f3554d1c927f42a55553fa3fecc5be6408a05126ed4434d5ef5f7889eacac7cd1eaa20f62463a44aceb40dd430372c9ed941f16663c73ed265
7
- data.tar.gz: e319a27d550e95ad2ca44433f2d83410385e0b370706e129a7aa9242ab1616ac5a43e2a4d8c3c0d62cee0ef8d8efe4e9f8a994081040ee54fad377342a37ffc4
6
+ metadata.gz: '04868324b3b929dcfab8299522ffff93a2c527d30b3bfea8f1aa6dfed5890d8ca5f9e4536ad8434e872e71a07239643ae1727ad65db65ce161c84e27b28e4fe3'
7
+ data.tar.gz: 0570f0c836854f909616af623f4b7660f641852bc1f68f6de1a325ff1ee1c56347500d068b03ac100846619a8e0eb5aebd4a279bf6ef33e4d2dce6b0fd1351c3
@@ -2,6 +2,9 @@ module Dscf
2
2
  module Marketplace
3
3
  class BusinessesController < ApplicationController
4
4
  include Dscf::Core::Common
5
+ include Dscf::Core::ReviewableController
6
+
7
+ reviewable_model Dscf::Core::Business
5
8
 
6
9
  def has_business
7
10
  has_business = current_user&.businesses&.exists? || false
@@ -54,17 +57,41 @@ module Dscf
54
57
  end
55
58
 
56
59
  def eager_loaded_associations
57
- [ :business_type, :user, :documents ]
60
+ [
61
+ :business_type, :user, :documents,
62
+ reviews: {reviewed_by: :user}
63
+ ]
58
64
  end
59
65
 
60
66
  def default_serializer_includes
61
67
  {
62
- index: [ :business_type, :user, :documents ],
63
- show: [ :business_type, :user, :documents ],
64
- create: [ :business_type, :user, :documents ],
65
- update: [ :business_type, :user, :documents ]
68
+ index: [
69
+ :business_type, :user, :documents,
70
+ reviews: {reviewed_by: :user}
71
+ ],
72
+ show: [
73
+ :business_type, :user, :documents,
74
+ reviews: {reviewed_by: :user}
75
+ ],
76
+ create: [ :business_type, :user, :documents, :reviews ],
77
+ update: [
78
+ :business_type, :user, :documents,
79
+ reviews: {reviewed_by: :user}
80
+ ]
66
81
  }
67
82
  end
83
+
84
+ def allowed_order_columns
85
+ %w[id name description contact_email contact_phone tin_number created_at updated_at]
86
+ end
87
+
88
+ def render_success(message = nil, data: nil, serializer_options: {}, status: :ok)
89
+ if data.is_a?(Dscf::Core::Business) && data.respond_to?(:reviews)
90
+ includes = default_serializer_includes[:show] || []
91
+ serializer_options = serializer_options.merge(include: includes)
92
+ end
93
+ super
94
+ end
68
95
  end
69
96
  end
70
97
  end
@@ -19,9 +19,9 @@ module Dscf
19
19
  description = params[:description]
20
20
 
21
21
  if @obj.report_issue!(issue_type, quantity, description, current_user&.id)
22
- render_success("delivery_order_items.success.issue_reported", data: @obj)
22
+ render_success("delivery_order_items.success.issue_reported", data: @obj.delivery_order)
23
23
  else
24
- render_error("delivery_order_items.errors.report_issue_failed")
24
+ render_error("delivery_order_items.errors.report_issue")
25
25
  end
26
26
  end
27
27
 
@@ -86,7 +86,9 @@ module Dscf::Marketplace
86
86
  end
87
87
 
88
88
  def report_issue!(issue_type, quantity, description, reported_by)
89
- return false unless delivered? || picked_up?
89
+ return false unless delivered? || picked_up? || pending?
90
+ return false unless [ "damaged", "missing" ].include?(issue_type)
91
+ return false if quantity > self.quantity
90
92
 
91
93
  update!(
92
94
  status: issue_type.to_sym, # :damaged or :missing
@@ -7,6 +7,9 @@ module Dscf
7
7
  belongs_to :business_type
8
8
  belongs_to :user
9
9
  has_many :documents
10
+
11
+ # ✅ REQUIRED: Add reviews association
12
+ has_many :reviews
10
13
  end
11
14
  end
12
15
  end
@@ -353,12 +353,22 @@ en:
353
353
  create: "Business created successfully"
354
354
  update: "Business updated successfully"
355
355
  destroy: "Business deleted successfully"
356
+ # ✅ ADD: Review actions
357
+ approve: "Business approved successfully"
358
+ reject: "Business rejected successfully"
359
+ request_modification: "Modification requested for business successfully"
360
+ resubmit: "Business resubmitted successfully"
356
361
  errors:
357
362
  index: "Failed to retrieve businesses"
358
363
  show: "Failed to retrieve business details"
359
364
  create: "Failed to create business"
360
365
  update: "Failed to update business"
361
366
  destroy: "Failed to delete business"
367
+ # ✅ ADD: Review action errors
368
+ approve: "Failed to approve business"
369
+ reject: "Failed to reject business"
370
+ request_modification: "Failed to request modification for business"
371
+ resubmit: "Failed to resubmit business"
362
372
 
363
373
  businesses:
364
374
  success:
data/config/routes.rb CHANGED
@@ -24,6 +24,12 @@ Dscf::Marketplace::Engine.routes.draw do
24
24
  get "has_business"
25
25
  get "my_businesses"
26
26
  end
27
+ member do
28
+ patch :approve
29
+ patch :reject
30
+ patch :request_modification
31
+ patch :resubmit
32
+ end
27
33
  end
28
34
 
29
35
  # Trading Models
@@ -20,6 +20,11 @@ module Dscf
20
20
  end
21
21
 
22
22
  require "active_storage/engine"
23
+
24
+ # Extend core Business model with ReviewableModel for review workflow
25
+ config.to_prepare do
26
+ Dscf::Core::Business.include Dscf::Core::ReviewableModel if defined?(Dscf::Core::Business)
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.4.6".freeze
3
+ VERSION = "0.4.8".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.4.6
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-07 00:00:00.000000000 Z
10
+ date: 2025-10-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails