dscf-marketplace 0.2.2 → 0.2.3

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: b03c9932cc3e31e46ea8ac2689f410b4f78b0cd950340a780b52e67abba8693c
4
- data.tar.gz: cef9643cb87044521d76d31f930affdeb899cc35a7ab67f9f129b346fd05dfdf
3
+ metadata.gz: 6369ee5595ca023697c774365dee93c16a985614fc46057ee9effd1e2120a244
4
+ data.tar.gz: 696e16ed8bac9ba0b214979d69b3b133c3ea5a32374bc44dd7ef9db0253bac6c
5
5
  SHA512:
6
- metadata.gz: cd00154351d1e038a1f375c2016db715d75ddb8808f8a1e30cebb234eb1f25f4dbaa160bdd8446b897a8542a08f064bee63b89e981dc36b05bd589b2638c4533
7
- data.tar.gz: c0f0e1b6c4fb9f5dcc8f1bd442058fc9494f0366819e0561ef228141755e3870217ff8512052894857655c55657114c395dd69aa5e84d77f6163bbd42db01395
6
+ metadata.gz: 218769eb0baba77cb42ec31c7519ea60ad1ed2483135446a98970cf18b928dc1ccc29a44dcdc941c144ac94cdf9098400628b9e521b4956f8bfe10c51913616b
7
+ data.tar.gz: aedbbb4601fab05aa6ce8e60470609286b71d5b3b6e7f9da201337073e12b5255c151fc16de074083c9511cbf10c6ff1d86d140cee6ae66bb95d1bf20df93d21
@@ -32,6 +32,18 @@ module Dscf
32
32
  render_error(error: e.message)
33
33
  end
34
34
 
35
+ def my_businesses
36
+ service = MyResourceService.new(current_user)
37
+ businesses = service.my_businesses(params)
38
+
39
+ options = {
40
+ include: default_serializer_includes[:index] || [],
41
+ meta: {resource_type: "my_businesses"}
42
+ }
43
+
44
+ render_success("businesses.success.index", data: businesses, serializer_options: options)
45
+ end
46
+
35
47
  private
36
48
 
37
49
  def model_params
@@ -30,6 +30,18 @@ module Dscf
30
30
  end
31
31
  end
32
32
 
33
+ def my_listings
34
+ service = MyResourceService.new(current_user)
35
+ listings = service.my_listings(params)
36
+
37
+ options = {
38
+ include: default_serializer_includes[:index] || [],
39
+ meta: {resource_type: "my_listings"}
40
+ }
41
+
42
+ render_success("listings.success.index", data: listings, serializer_options: options)
43
+ end
44
+
33
45
  private
34
46
 
35
47
  def model_params
@@ -32,6 +32,18 @@ module Dscf
32
32
  end
33
33
  end
34
34
 
35
+ def my_orders
36
+ service = MyResourceService.new(current_user)
37
+ orders = service.my_orders(params)
38
+
39
+ options = {
40
+ include: default_serializer_includes[:index] || [],
41
+ meta: {resource_type: "my_orders"}
42
+ }
43
+
44
+ render_success("orders.success.index", data: orders, serializer_options: options)
45
+ end
46
+
35
47
  private
36
48
 
37
49
  def model_params
@@ -30,6 +30,18 @@ module Dscf
30
30
  end
31
31
  end
32
32
 
33
+ def my_quotes
34
+ service = MyResourceService.new(current_user)
35
+ quotes = service.my_quotes(params)
36
+
37
+ options = {
38
+ include: default_serializer_includes[:index] || [],
39
+ meta: {resource_type: "my_quotes"}
40
+ }
41
+
42
+ render_success("quotations.success.index", data: quotes, serializer_options: options)
43
+ end
44
+
33
45
  private
34
46
 
35
47
  def model_params
@@ -21,6 +21,18 @@ module Dscf
21
21
  end
22
22
  end
23
23
 
24
+ def my_rfqs
25
+ service = MyResourceService.new(current_user)
26
+ rfqs = service.my_rfqs(params)
27
+
28
+ options = {
29
+ include: default_serializer_includes[:index] || [],
30
+ meta: {resource_type: "my_rfqs"}
31
+ }
32
+
33
+ render_success("request_for_quotations.success.index", data: rfqs, serializer_options: options)
34
+ end
35
+
24
36
  private
25
37
 
26
38
  def model_params
@@ -3,6 +3,18 @@ module Dscf
3
3
  class SupplierProductsController < ApplicationController
4
4
  include Dscf::Core::Common
5
5
 
6
+ def my_products
7
+ service = MyResourceService.new(current_user)
8
+ products = service.my_products(params)
9
+
10
+ options = {
11
+ include: default_serializer_includes[:index] || [],
12
+ meta: {resource_type: "my_products"}
13
+ }
14
+
15
+ render_success("supplier_products.success.index", data: products, serializer_options: options)
16
+ end
17
+
6
18
  private
7
19
 
8
20
  def model_params
@@ -0,0 +1,62 @@
1
+ module Dscf
2
+ module Marketplace
3
+ class MyResourceService
4
+ def initialize(current_user)
5
+ @current_user = current_user
6
+ end
7
+
8
+ def my_orders(params = {})
9
+ orders = Dscf::Marketplace::Order.where(user: @current_user)
10
+ .includes(:quotation, :listing, :user, :delivery_order, :order_items)
11
+
12
+ apply_filters(orders, params)
13
+ end
14
+
15
+ def my_rfqs(params = {})
16
+ rfqs = Dscf::Marketplace::RequestForQuotation.where(user: @current_user)
17
+ .includes(:user, :selected_quotation, :rfq_items, :quotations)
18
+
19
+ apply_filters(rfqs, params)
20
+ end
21
+
22
+ def my_quotes(params = {})
23
+ quotes = Dscf::Marketplace::Quotation.joins(:request_for_quotation)
24
+ .where(dscf_marketplace_request_for_quotations: {user_id: @current_user.id})
25
+ .includes(:request_for_quotation, :business, :quotation_items, :order)
26
+
27
+ apply_filters(quotes, params)
28
+ end
29
+
30
+ def my_businesses(params = {})
31
+ @current_user.businesses.includes(:business_type, :user, :documents)
32
+ end
33
+
34
+ def my_listings(params = {})
35
+ listings = Dscf::Marketplace::Listing.joins(:business)
36
+ .where(dscf_core_businesses: {user_id: @current_user.id})
37
+ .includes(:business, :supplier_product, :order_items)
38
+
39
+ apply_filters(listings, params)
40
+ end
41
+
42
+ def my_products(params = {})
43
+ products = Dscf::Marketplace::SupplierProduct.joins(:business)
44
+ .where(dscf_core_businesses: {user_id: @current_user.id})
45
+ .includes(:business, :product, :listings)
46
+
47
+ apply_filters(products, params)
48
+ end
49
+
50
+ private
51
+
52
+ def apply_filters(query, params)
53
+ # Apply Ransack filtering
54
+ if params[:q].present?
55
+ query = query.ransack(params[:q]).result
56
+ end
57
+
58
+ query
59
+ end
60
+ end
61
+ end
62
+ end
data/config/routes.rb CHANGED
@@ -19,12 +19,16 @@ Dscf::Marketplace::Engine.routes.draw do
19
19
  resources :businesses do
20
20
  collection do
21
21
  get "has_business"
22
+ get "my_businesses"
22
23
  end
23
24
  end
24
25
 
25
26
  # Trading Models
26
27
  resources :supplier_products do
27
28
  resources :listings, only: [ :index ]
29
+ collection do
30
+ get "my_products"
31
+ end
28
32
  end
29
33
 
30
34
  resources :listings do
@@ -33,6 +37,9 @@ Dscf::Marketplace::Engine.routes.draw do
33
37
  post "pause"
34
38
  post "sold_out"
35
39
  end
40
+ collection do
41
+ get "my_listings"
42
+ end
36
43
  end
37
44
 
38
45
  # RFQ System
@@ -43,6 +50,9 @@ Dscf::Marketplace::Engine.routes.draw do
43
50
  post "send_rfq"
44
51
  post "close"
45
52
  end
53
+ collection do
54
+ get "my_rfqs"
55
+ end
46
56
  end
47
57
 
48
58
  resources :rfq_items, only: [ :index, :show, :update, :create, :destroy ]
@@ -54,6 +64,9 @@ Dscf::Marketplace::Engine.routes.draw do
54
64
  post "reject"
55
65
  post "send_quotation"
56
66
  end
67
+ collection do
68
+ get "my_quotes"
69
+ end
57
70
  end
58
71
 
59
72
  resources :quotation_items, only: [ :index, :show, :update, :create, :destroy ]
@@ -66,6 +79,9 @@ Dscf::Marketplace::Engine.routes.draw do
66
79
  post "cancel"
67
80
  post "complete"
68
81
  end
82
+ collection do
83
+ get "my_orders"
84
+ end
69
85
  end
70
86
 
71
87
  resources :order_items, only: [ :index, :show, :update, :create, :destroy ]
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.2.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-marketplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
@@ -468,6 +468,7 @@ files:
468
468
  - app/serializers/dscf/marketplace/supplier_product_serializer.rb
469
469
  - app/serializers/dscf/marketplace/unit_conversion_serializer.rb
470
470
  - app/serializers/dscf/marketplace/unit_serializer.rb
471
+ - app/services/dscf/marketplace/my_resource_service.rb
471
472
  - config/locales/en.yml
472
473
  - config/routes.rb
473
474
  - db/migrate/20250827172043_create_dscf_marketplace_categories.rb