dscf-marketplace 0.1.8 → 0.2.0
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/app/controllers/dscf/marketplace/application_controller.rb +2 -0
- data/app/controllers/dscf/marketplace/categories_controller.rb +26 -0
- data/app/controllers/dscf/marketplace/delivery_order_items_controller.rb +64 -0
- data/app/controllers/dscf/marketplace/delivery_orders_controller.rb +72 -0
- data/app/controllers/dscf/marketplace/delivery_vehicles_controller.rb +28 -0
- data/app/controllers/dscf/marketplace/listings_controller.rb +55 -0
- data/app/controllers/dscf/marketplace/order_items_controller.rb +29 -0
- data/app/controllers/dscf/marketplace/orders_controller.rb +58 -0
- data/app/controllers/dscf/marketplace/products_controller.rb +30 -0
- data/app/controllers/dscf/marketplace/quotation_items_controller.rb +28 -0
- data/app/controllers/dscf/marketplace/quotations_controller.rb +56 -0
- data/app/controllers/dscf/marketplace/request_for_quotations_controller.rb +46 -0
- data/app/controllers/dscf/marketplace/rfq_items_controller.rb +28 -0
- data/app/controllers/dscf/marketplace/supplier_products_controller.rb +29 -0
- data/app/controllers/dscf/marketplace/unit_conversions_controller.rb +28 -0
- data/app/controllers/dscf/marketplace/units_controller.rb +26 -0
- data/app/models/dscf/marketplace/category.rb +9 -0
- data/app/models/dscf/marketplace/delivery_order.rb +15 -0
- data/app/models/dscf/marketplace/delivery_order_item.rb +9 -0
- data/app/models/dscf/marketplace/delivery_vehicle.rb +9 -0
- data/app/models/dscf/marketplace/listing.rb +9 -0
- data/app/models/dscf/marketplace/order.rb +9 -0
- data/app/models/dscf/marketplace/order_item.rb +9 -0
- data/app/models/dscf/marketplace/product.rb +9 -0
- data/app/models/dscf/marketplace/quotation.rb +9 -0
- data/app/models/dscf/marketplace/quotation_item.rb +51 -12
- data/app/models/dscf/marketplace/request_for_quotation.rb +9 -0
- data/app/models/dscf/marketplace/rfq_item.rb +9 -0
- data/app/models/dscf/marketplace/supplier_product.rb +9 -0
- data/app/models/dscf/marketplace/unit.rb +9 -0
- data/app/models/dscf/marketplace/unit_conversion.rb +9 -0
- data/app/serializers/dscf/marketplace/category_serializer.rb +11 -0
- data/app/serializers/dscf/marketplace/delivery_order_item_serializer.rb +17 -0
- data/app/serializers/dscf/marketplace/delivery_order_serializer.rb +17 -0
- data/app/serializers/dscf/marketplace/delivery_vehicle_serializer.rb +12 -0
- data/app/serializers/dscf/marketplace/listing_serializer.rb +13 -0
- data/app/serializers/dscf/marketplace/order_item_serializer.rb +16 -0
- data/app/serializers/dscf/marketplace/order_serializer.rb +15 -0
- data/app/serializers/dscf/marketplace/product_serializer.rb +13 -0
- data/app/serializers/dscf/marketplace/quotation_item_serializer.rb +16 -0
- data/app/serializers/dscf/marketplace/quotation_serializer.rb +14 -0
- data/app/serializers/dscf/marketplace/request_for_quotation_serializer.rb +13 -0
- data/app/serializers/dscf/marketplace/rfq_item_serializer.rb +14 -0
- data/app/serializers/dscf/marketplace/supplier_product_serializer.rb +13 -0
- data/app/serializers/dscf/marketplace/unit_conversion_serializer.rb +11 -0
- data/app/serializers/dscf/marketplace/unit_serializer.rb +9 -0
- data/config/locales/en.yml +254 -0
- data/config/routes.rb +85 -0
- data/lib/dscf/marketplace/version.rb +1 -1
- data/spec/factories/dscf/marketplace/delivery_order_items.rb +1 -1
- data/spec/factories/dscf/marketplace/quotation_items.rb +2 -2
- metadata +32 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df198307c66d8356b9c6087b33670c4658047882587a996d835cd993688f1928
|
4
|
+
data.tar.gz: 5e020f16c458e74f374462d732c6fe746e5cd122489b4b3c5bff026a9845bd1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a504501c9c8235f1a634e8f0b62c527c1383c87fa36f08c79e2f89e22c4ced206b63bbc80330eb11a44e141dea08ebae506a97f2dcb565ad4dbd7ab58544405
|
7
|
+
data.tar.gz: df8f9d49b2d9a47cdf68a87e12d07497d8ccffa08a5ee9678982ba5fbc468924a24245f844dfa8a1976f6cda468f91b022cd367a9ef573cbcda7a1eb19d242b6
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class CategoriesController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:category).permit(:name, :description, :parent_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def eager_loaded_associations
|
13
|
+
[ :parent, :subcategories, :products ]
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_serializer_includes
|
17
|
+
{
|
18
|
+
index: [ :parent ],
|
19
|
+
show: [ :parent, :subcategories, :products ],
|
20
|
+
create: [ :parent ],
|
21
|
+
update: [ :parent ]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class DeliveryOrderItemsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def receiver_confirm
|
7
|
+
@obj = find_record
|
8
|
+
if @obj.receiver_confirm!(params[:confirmed_quantity], params[:notes], current_user&.id)
|
9
|
+
render_success("delivery_order_items.success.receiver_confirmed", data: @obj)
|
10
|
+
else
|
11
|
+
render_error("delivery_order_items.errors.receiver_confirm_failed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def report_issue
|
16
|
+
@obj = find_record
|
17
|
+
issue_type = params[:issue_type]
|
18
|
+
quantity = params[:quantity]
|
19
|
+
description = params[:description]
|
20
|
+
|
21
|
+
if @obj.report_issue!(issue_type, quantity, description, current_user&.id)
|
22
|
+
render_success("delivery_order_items.success.issue_reported", data: @obj)
|
23
|
+
else
|
24
|
+
render_error("delivery_order_items.errors.report_issue_failed")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def dispute_delivery
|
29
|
+
@obj = find_record
|
30
|
+
reason = params[:reason]
|
31
|
+
|
32
|
+
if @obj.dispute_delivery!(reason, current_user&.id)
|
33
|
+
render_success("delivery_order_items.success.delivery_disputed", data: @obj)
|
34
|
+
else
|
35
|
+
render_error("delivery_order_items.errors.dispute_delivery_failed")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def model_params
|
42
|
+
params.require(:delivery_order_item).permit(
|
43
|
+
:delivery_order_id, :order_item_id, :pickup_address_id, :dropoff_address_id,
|
44
|
+
:quantity, :status, :pickup_verified_quantity, :dropoff_verified_quantity,
|
45
|
+
:damaged_quantity, :missing_quantity, :receiver_confirmed_by,
|
46
|
+
:receiver_confirmed_at, :receiver_notes, :handoff_checklist_completed
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def eager_loaded_associations
|
51
|
+
[ :delivery_order, :order_item, :pickup_address, :dropoff_address ]
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_serializer_includes
|
55
|
+
{
|
56
|
+
index: [ :delivery_order, :order_item ],
|
57
|
+
show: [ :delivery_order, :order_item, :pickup_address, :dropoff_address ],
|
58
|
+
create: [ :delivery_order, :order_item ],
|
59
|
+
update: [ :delivery_order, :order_item ]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class DeliveryOrdersController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def index
|
7
|
+
@objs = DeliveryOrder.all
|
8
|
+
render_success("delivery_orders.index.success", data: @objs, serializer_options: {include: default_serializer_includes[:index]})
|
9
|
+
end
|
10
|
+
|
11
|
+
def pickup
|
12
|
+
@obj = find_record
|
13
|
+
if @obj.pickup!
|
14
|
+
render_success("delivery_orders.success.picked_up", data: @obj)
|
15
|
+
else
|
16
|
+
render_error("delivery_orders.errors.pickup_failed")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_delivery
|
21
|
+
@obj = find_record
|
22
|
+
if @obj.start_delivery!
|
23
|
+
render_success("delivery_orders.success.delivery_started", data: @obj)
|
24
|
+
else
|
25
|
+
render_error("delivery_orders.errors.start_delivery_failed")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def complete_delivery
|
30
|
+
@obj = find_record
|
31
|
+
if @obj.complete_delivery!
|
32
|
+
render_success("delivery_orders.success.delivery_completed", data: @obj)
|
33
|
+
else
|
34
|
+
render_error("delivery_orders.errors.complete_delivery_failed")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def mark_failed
|
39
|
+
@obj = find_record
|
40
|
+
reason = params[:reason]
|
41
|
+
if @obj.mark_failed!(reason)
|
42
|
+
render_success("delivery_orders.success.marked_failed", data: @obj)
|
43
|
+
else
|
44
|
+
render_error("delivery_orders.errors.mark_failed_failed")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def model_params
|
51
|
+
params.require(:delivery_order).permit(
|
52
|
+
:driver_id, :pickup_address_id, :delivery_vehicle_id, :status,
|
53
|
+
:vehicle_type, :estimated_delivery_price, :actual_delivery_price,
|
54
|
+
:estimated_delivery_time, :actual_delivery_time, :delivery_notes
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def eager_loaded_associations
|
59
|
+
[ :driver, :pickup_address, :delivery_vehicle, :delivery_order_items, :marketplace_orders ]
|
60
|
+
end
|
61
|
+
|
62
|
+
def default_serializer_includes
|
63
|
+
{
|
64
|
+
index: [ :driver, :pickup_address, :delivery_vehicle ],
|
65
|
+
show: [ :driver, :pickup_address, :delivery_vehicle, :delivery_order_items, :marketplace_orders ],
|
66
|
+
create: [ :driver, :pickup_address, :delivery_vehicle ],
|
67
|
+
update: [ :driver, :pickup_address, :delivery_vehicle ]
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class DeliveryVehiclesController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:delivery_vehicle).permit(
|
10
|
+
:driver_id, :plate_number, :vehicle_type, :year, :brand, :model, :color
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def eager_loaded_associations
|
15
|
+
[ :driver, :delivery_orders ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_serializer_includes
|
19
|
+
{
|
20
|
+
index: [ :driver ],
|
21
|
+
show: [ :driver, :delivery_orders ],
|
22
|
+
create: [ :driver ],
|
23
|
+
update: [ :driver ]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class ListingsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def activate
|
7
|
+
@obj = find_record
|
8
|
+
if @obj.update(status: :active)
|
9
|
+
render_success("listings.success.activated", data: @obj)
|
10
|
+
else
|
11
|
+
render_error("listings.errors.activate_failed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def pause
|
16
|
+
@obj = find_record
|
17
|
+
if @obj.update(status: :paused)
|
18
|
+
render_success("listings.success.paused", data: @obj)
|
19
|
+
else
|
20
|
+
render_error("listings.errors.pause_failed")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def sold_out
|
25
|
+
@obj = find_record
|
26
|
+
if @obj.update(status: :sold_out)
|
27
|
+
render_success("listings.success.sold_out", data: @obj)
|
28
|
+
else
|
29
|
+
render_error("listings.errors.sold_out_failed")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def model_params
|
36
|
+
params.require(:listing).permit(
|
37
|
+
:business_id, :supplier_product_id, :price, :quantity, :status
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def eager_loaded_associations
|
42
|
+
[ :business, :supplier_product, :order_items ]
|
43
|
+
end
|
44
|
+
|
45
|
+
def default_serializer_includes
|
46
|
+
{
|
47
|
+
index: [ :business, :supplier_product ],
|
48
|
+
show: [ :business, :supplier_product, :order_items ],
|
49
|
+
create: [ :business, :supplier_product ],
|
50
|
+
update: [ :business, :supplier_product ]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class OrderItemsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:order_item).permit(
|
10
|
+
:order_id, :quotation_item_id, :listing_id,
|
11
|
+
:product_id, :unit_id, :quantity, :unit_price, :status
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def eager_loaded_associations
|
16
|
+
[ :order, :quotation_item, :listing, :product, :unit ]
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_serializer_includes
|
20
|
+
{
|
21
|
+
index: [ :product, :unit ],
|
22
|
+
show: [ :order, :quotation_item, :listing, :product, :unit ],
|
23
|
+
create: [ :product, :unit ],
|
24
|
+
update: [ :product, :unit ]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class OrdersController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def confirm
|
7
|
+
@obj = find_record
|
8
|
+
if @obj.confirm!
|
9
|
+
render_success("orders.success.confirmed", data: @obj)
|
10
|
+
else
|
11
|
+
render_error("orders.errors.confirm_failed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def cancel
|
16
|
+
@obj = find_record
|
17
|
+
if @obj.update(status: :cancelled)
|
18
|
+
@obj.order_items.update_all(status: OrderItem.statuses[:cancelled])
|
19
|
+
render_success("orders.success.cancelled", data: @obj)
|
20
|
+
else
|
21
|
+
render_error("orders.errors.cancel_failed")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete
|
26
|
+
@obj = find_record
|
27
|
+
if @obj.can_be_completed? && @obj.update(status: :completed)
|
28
|
+
@obj.order_items.update_all(status: OrderItem.statuses[:completed])
|
29
|
+
render_success("orders.success.completed", data: @obj)
|
30
|
+
else
|
31
|
+
render_error("orders.errors.complete_failed")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def model_params
|
38
|
+
params.require(:order).permit(
|
39
|
+
:quotation_id, :listing_id, :user_id, :delivery_order_id,
|
40
|
+
:order_type, :status, :fulfillment_type
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def eager_loaded_associations
|
45
|
+
[ :quotation, :listing, :user, :delivery_order, :order_items ]
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_serializer_includes
|
49
|
+
{
|
50
|
+
index: [ :user, :quotation, :listing ],
|
51
|
+
show: [ :user, :quotation, :listing, :delivery_order, :order_items ],
|
52
|
+
create: [ :user, :quotation, :listing ],
|
53
|
+
update: [ :user, :quotation, :listing ]
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class ProductsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:product).permit(
|
10
|
+
:sku, :name, :description, :category_id, :unit_id,
|
11
|
+
:base_price, :base_quantity, :business_only,
|
12
|
+
:thumbnail, images: []
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def eager_loaded_associations
|
17
|
+
[ :category, :unit, :supplier_products ]
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_serializer_includes
|
21
|
+
{
|
22
|
+
index: [ :category, :unit ],
|
23
|
+
show: [ :category, :unit, :supplier_products ],
|
24
|
+
create: [ :category, :unit ],
|
25
|
+
update: [ :category, :unit ]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class QuotationItemsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:quotation_item).permit(
|
10
|
+
:quotation_id, :rfq_item_id, :product_id, :unit_id, :quantity, :unit_price
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def eager_loaded_associations
|
15
|
+
[ :quotation, :rfq_item, :product, :unit ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_serializer_includes
|
19
|
+
{
|
20
|
+
index: [ :quotation, :rfq_item, :product, :unit ],
|
21
|
+
show: [ :quotation, :rfq_item, :product, :unit ],
|
22
|
+
create: [ :quotation, :rfq_item, :product, :unit ],
|
23
|
+
update: [ :quotation, :rfq_item, :product, :unit ]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class QuotationsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def accept
|
7
|
+
@obj = find_record
|
8
|
+
if @obj.accept!
|
9
|
+
render_success("quotations.success.accepted", data: @obj)
|
10
|
+
else
|
11
|
+
render_error("quotations.errors.accept_failed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def reject
|
16
|
+
@obj = find_record
|
17
|
+
if @obj.reject!
|
18
|
+
render_success("quotations.success.rejected", data: @obj)
|
19
|
+
else
|
20
|
+
render_error("quotations.errors.reject_failed")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def send_quotation
|
25
|
+
@obj = find_record
|
26
|
+
if @obj.send_quotation!
|
27
|
+
render_success("quotations.success.sent", data: @obj)
|
28
|
+
else
|
29
|
+
render_error("quotations.errors.send_failed")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def model_params
|
36
|
+
params.require(:quotation).permit(
|
37
|
+
:request_for_quotation_id, :business_id, :total_price,
|
38
|
+
:delivery_date, :valid_until, :status, :notes
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def eager_loaded_associations
|
43
|
+
[ :request_for_quotation, :business, :quotation_items, :order ]
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_serializer_includes
|
47
|
+
{
|
48
|
+
index: [ :request_for_quotation, :business ],
|
49
|
+
show: [ :request_for_quotation, :business, :quotation_items, :order ],
|
50
|
+
create: [ :request_for_quotation, :business ],
|
51
|
+
update: [ :request_for_quotation, :business ]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class RequestForQuotationsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
def send_rfq
|
7
|
+
@obj = find_record
|
8
|
+
if @obj.draft? && @obj.update(status: :sent)
|
9
|
+
render_success("request_for_quotations.success.sent", data: @obj)
|
10
|
+
else
|
11
|
+
render_error("request_for_quotations.errors.send_failed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def close
|
16
|
+
@obj = find_record
|
17
|
+
if (@obj.sent? || @obj.responded?) && @obj.update(status: :closed)
|
18
|
+
render_success("request_for_quotations.success.closed", data: @obj)
|
19
|
+
else
|
20
|
+
render_error("request_for_quotations.errors.close_failed")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def model_params
|
27
|
+
params.require(:request_for_quotation).permit(
|
28
|
+
:user_id, :selected_quotation_id, :status, :notes
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def eager_loaded_associations
|
33
|
+
[ :user, :selected_quotation, :rfq_items, :quotations ]
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_serializer_includes
|
37
|
+
{
|
38
|
+
index: [ :user ],
|
39
|
+
show: [ :user, :selected_quotation, :rfq_items, :quotations ],
|
40
|
+
create: [ :user ],
|
41
|
+
update: [ :user ]
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class RfqItemsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:rfq_item).permit(
|
10
|
+
:request_for_quotation_id, :product_id, :unit_id, :quantity, :notes
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def eager_loaded_associations
|
15
|
+
[ :request_for_quotation, :product, :unit, :quotation_items ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_serializer_includes
|
19
|
+
{
|
20
|
+
index: [ :request_for_quotation, :product, :unit ],
|
21
|
+
show: [ :request_for_quotation, :product, :unit, :quotation_items ],
|
22
|
+
create: [ :request_for_quotation, :product, :unit ],
|
23
|
+
update: [ :request_for_quotation, :product, :unit ]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class SupplierProductsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:supplier_product).permit(
|
10
|
+
:business_id, :product_id, :supplier_price, :available_quantity,
|
11
|
+
:minimum_order_quantity, :status
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def eager_loaded_associations
|
16
|
+
[ :business, :product, :listings ]
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_serializer_includes
|
20
|
+
{
|
21
|
+
index: [ :business, :product ],
|
22
|
+
show: [ :business, :product, :listings ],
|
23
|
+
create: [ :business, :product ],
|
24
|
+
update: [ :business, :product ]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class UnitConversionsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:unit_conversion).permit(
|
10
|
+
:from_unit_id, :to_unit_id, :conversion_factor, :notes
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def eager_loaded_associations
|
15
|
+
[ :from_unit, :to_unit ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_serializer_includes
|
19
|
+
{
|
20
|
+
index: [ :from_unit, :to_unit ],
|
21
|
+
show: [ :from_unit, :to_unit ],
|
22
|
+
create: [ :from_unit, :to_unit ],
|
23
|
+
update: [ :from_unit, :to_unit ]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Marketplace
|
3
|
+
class UnitsController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def model_params
|
9
|
+
params.require(:unit).permit(:code, :name, :unit_type)
|
10
|
+
end
|
11
|
+
|
12
|
+
def eager_loaded_associations
|
13
|
+
[ :unit_conversions ]
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_serializer_includes
|
17
|
+
{
|
18
|
+
index: [ :unit_conversions ],
|
19
|
+
show: [ :unit_conversions ],
|
20
|
+
create: [],
|
21
|
+
update: []
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -12,6 +12,15 @@ module Dscf
|
|
12
12
|
|
13
13
|
scope :root_categories, -> { where(parent_id: nil) }
|
14
14
|
|
15
|
+
# Ransack configuration for secure filtering
|
16
|
+
def self.ransackable_attributes(_auth_object = nil)
|
17
|
+
%w[id name description parent_id created_at updated_at]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.ransackable_associations(_auth_object = nil)
|
21
|
+
%w[parent subcategories products]
|
22
|
+
end
|
23
|
+
|
15
24
|
def root?
|
16
25
|
parent_id.nil?
|
17
26
|
end
|
@@ -18,6 +18,21 @@ module Dscf::Marketplace
|
|
18
18
|
|
19
19
|
before_save :calculate_actual_delivery_price, if: :status_changed?
|
20
20
|
|
21
|
+
# Ransack configuration for secure filtering
|
22
|
+
def self.ransackable_attributes(_auth_object = nil)
|
23
|
+
%w[id driver_id pickup_address_id delivery_vehicle_id status vehicle_type estimated_delivery_price actual_delivery_price estimated_delivery_time actual_delivery_time delivery_notes created_at updated_at]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Override ransack to handle JSON fields
|
27
|
+
def self.ransack(params = {}, options = {})
|
28
|
+
params ||= {}
|
29
|
+
super(params.except("optimized_route"), options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.ransackable_associations(_auth_object = nil)
|
33
|
+
%w[driver pickup_address delivery_vehicle delivery_order_items marketplace_orders]
|
34
|
+
end
|
35
|
+
|
21
36
|
def pickup!
|
22
37
|
return false unless assigned?
|
23
38
|
update!(status: :picked_up, actual_delivery_time: Time.current)
|