dscf-marketplace 0.9.6 → 0.9.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: 888e597416339864fb9f310837a1624135b615dbf8ec21d875594a05bab42632
4
- data.tar.gz: a0476fcb98220d993ce5cc5b63c0f497b2d887c54a9397e19399750c2fc57a33
3
+ metadata.gz: 96faa437c564d4a08d4df63b8e1143c8e69da546d8e576e03d30bd2c99443e50
4
+ data.tar.gz: 58eeb5fed2f4afea0a88dd25f55d2bfc791a7d7f488a7be46357fcc4b79597fb
5
5
  SHA512:
6
- metadata.gz: f5c7d51bdf7f4d9923416be26301bb9c52dc15620634aa9cbf7c752607a5a31bb54264f73cf1df4f021da6ed5a403a23a93e64d581c82cc7c0718df767517726
7
- data.tar.gz: 0f16faf59dbf7676fa2ef70ae16a04d8e37a57eb359011e381a67038be06cee41cf1ed234561410869e8f03c6d76497e9d4307aee9bab24e656464ab137c7f1f
6
+ metadata.gz: cd51195fca94e7f6018aca92c64620f1f686a5b1584858add1afb1ceb0ee8a34b09e90fd27e9681dadbaef3a514741109c5a293aee3aa57c905f11df962cda4f
7
+ data.tar.gz: c9bc4eefa1acdd394eb3d23ae3a57f60126ccdb5dd698e64050c4ca8f48d2364a99c06266aff03b9d84b90a9d45ea2881e847d98a2b58a51335ee2751f245230
@@ -85,7 +85,7 @@ module Dscf
85
85
  authorize @obj, :show?
86
86
  invoice = @obj.order_invoice
87
87
  if invoice&.pdf_file&.attached?
88
- redirect_to rails_blob_url(invoice.pdf_file, disposition: "attachment")
88
+ redirect_to rails_storage_proxy_url(invoice.pdf_file, disposition: "attachment")
89
89
  else
90
90
  render_error("orders.errors.no_invoice")
91
91
  end
@@ -179,6 +179,21 @@ module Dscf
179
179
  render_error(errors: e.message, status: :unprocessable_entity)
180
180
  end
181
181
 
182
+ def confirm_item
183
+ obj = find_record
184
+ authorize obj, :supplier_confirm?
185
+
186
+ item = obj.order_items.find(params[:order_item_id])
187
+ confirmed = params[:confirmed] != false
188
+ reason = params[:reason]
189
+ Dscf::Marketplace::OrderSplittingService.confirm_item(obj, item, confirmed: confirmed, reason: reason)
190
+
191
+ create_notification_for_order(obj, confirmed ? :supplier_confirmed : :supplier_rejected, reason: reason)
192
+ render_success(data: obj.reload, serializer_options: { include: default_serializer_includes[:show] || [] })
193
+ rescue => e
194
+ render_error(errors: e.message, status: :unprocessable_entity)
195
+ end
196
+
182
197
  def retailer_confirm
183
198
  obj = find_record
184
199
  authorize obj, :confirm? # reuse existing or add specific
@@ -46,13 +46,13 @@ module Dscf::Marketplace
46
46
  def photo_url
47
47
  return nil unless photo.attached?
48
48
 
49
- Rails.application.routes.url_helpers.rails_blob_url(photo, only_path: true)
49
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(photo, only_path: true)
50
50
  end
51
51
 
52
52
  def national_id_url
53
53
  return nil unless national_id.attached?
54
54
 
55
- Rails.application.routes.url_helpers.rails_blob_url(national_id, only_path: true)
55
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(national_id, only_path: true)
56
56
  end
57
57
 
58
58
  private
@@ -8,6 +8,8 @@ module Dscf::Marketplace
8
8
  belongs_to :pickup_address, class_name: "Dscf::Core::Address"
9
9
  belongs_to :dropoff_address, class_name: "Dscf::Core::Address"
10
10
 
11
+ delegate :thumbnail_url, :images_urls, to: :order_item, allow_nil: true
12
+
11
13
  validates :delivery_order_id, presence: true
12
14
  validates :order_item_id, presence: true
13
15
  validates :quantity, presence: true, numericality: {greater_than: 0}
@@ -69,7 +69,7 @@ module Dscf
69
69
  return unless attachment.present?
70
70
  return if attachment.respond_to?(:attached?) && !attachment.attached?
71
71
 
72
- Rails.application.routes.url_helpers.rails_blob_url(attachment, **active_storage_url_options)
72
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(attachment, **active_storage_url_options)
73
73
  end
74
74
 
75
75
  def active_storage_url_options
@@ -6,6 +6,8 @@ module Dscf
6
6
  belongs_to :product, class_name: "Dscf::Marketplace::Product"
7
7
  belongs_to :unit, class_name: "Dscf::Marketplace::Unit"
8
8
 
9
+ delegate :thumbnail_url, :images_urls, to: :product, allow_nil: true
10
+
9
11
  validates :product_id, presence: true
10
12
  validates :quantity, presence: true, numericality: {greater_than: 0}
11
13
  validates :unit_id, presence: true
@@ -7,6 +7,8 @@ module Dscf
7
7
 
8
8
  has_many :quotation_items, class_name: "Dscf::Marketplace::QuotationItem", dependent: :destroy
9
9
 
10
+ delegate :thumbnail_url, :images_urls, to: :product, allow_nil: true
11
+
10
12
  validates :quantity, presence: true, numericality: {greater_than: 0}
11
13
  validates :notes, length: {maximum: 1000}, allow_blank: true
12
14
 
@@ -81,7 +81,7 @@ module Dscf::Marketplace
81
81
  return [] unless documents.attached?
82
82
 
83
83
  documents.map do |doc|
84
- Rails.application.routes.url_helpers.rails_blob_url(doc, only_path: true)
84
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(doc, only_path: true)
85
85
  end
86
86
  end
87
87
 
@@ -6,7 +6,8 @@ module Dscf
6
6
  :damaged_quantity, :missing_quantity, :receiver_confirmed_by,
7
7
  :receiver_confirmed_at, :receiver_notes, :handoff_checklist_completed,
8
8
  :created_at, :updated_at, :product_name, :unit_name, :verification_complete?,
9
- :has_discrepancy?, :discrepancy_amount, :requires_resolution?
9
+ :has_discrepancy?, :discrepancy_amount, :requires_resolution?,
10
+ :thumbnail_url, :images_urls
10
11
 
11
12
  belongs_to :delivery_order
12
13
  belongs_to :order_item
@@ -14,7 +14,7 @@ module Dscf
14
14
 
15
15
  url_options = Rails.application.config.x.active_storage_url_options || {}
16
16
  object.product_images.map do |image|
17
- Rails.application.routes.url_helpers.rails_blob_url(image, **url_options)
17
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(image, **url_options)
18
18
  end
19
19
  end
20
20
 
@@ -5,7 +5,7 @@ module Dscf
5
5
  :unit_price, :subtotal, :created_at, :updated_at, :product_name,
6
6
  :product_sku, :unit_name, :unit_code, :rfq_requested_quantity,
7
7
  :quantity_difference, :quantity_difference_percentage, :price_per_base_unit,
8
- :matches_rfq_request?, :can_create_order?
8
+ :matches_rfq_request?, :can_create_order?, :thumbnail_url, :images_urls
9
9
 
10
10
  belongs_to :quotation
11
11
  belongs_to :rfq_item
@@ -3,7 +3,8 @@ module Dscf
3
3
  class RfqItemSerializer < ActiveModel::Serializer
4
4
  attributes :id, :request_for_quotation_id, :product_id, :unit_id, :quantity, :notes,
5
5
  :created_at, :updated_at, :product_name, :product_sku, :unit_name,
6
- :unit_code, :quotation_count, :has_quotations?, :quoted_price_range
6
+ :unit_code, :quotation_count, :has_quotations?, :quoted_price_range,
7
+ :thumbnail_url, :images_urls
7
8
 
8
9
  belongs_to :request_for_quotation
9
10
  belongs_to :product
@@ -8,7 +8,7 @@ module Dscf
8
8
  def business_license_url
9
9
  return nil unless object.business_license.attached?
10
10
 
11
- Rails.application.routes.url_helpers.rails_blob_url(object.business_license, only_path: true)
11
+ Rails.application.routes.url_helpers.rails_storage_proxy_url(object.business_license, only_path: true)
12
12
  end
13
13
  end
14
14
  end
@@ -43,6 +43,20 @@ module Dscf
43
43
  end
44
44
  order
45
45
  end
46
+
47
+ # Per-source confirmation (requirements doc: "Supplier and aggregator order
48
+ # confirmation"). The aggregator confirms each sub-supplier / aggregator-store
49
+ # allocation individually; other-supplier items are confirmed by that supplier.
50
+ # Once every item has responded (confirmed or cancelled), the order advances
51
+ # to retailer confirmation.
52
+ def self.confirm_item(order, order_item, confirmed: true, reason: nil)
53
+ order_item.status = confirmed ? :confirmed : :cancelled
54
+ order_item.save!
55
+
56
+ order.reload
57
+ order.mark_waiting_retailer_confirmation! if order.supplier_confirmation_complete?
58
+ order_item
59
+ end
46
60
  end
47
61
  end
48
62
  end
data/config/routes.rb CHANGED
@@ -130,6 +130,7 @@ Dscf::Marketplace::Engine.routes.draw do
130
130
  post "assign_source"
131
131
  post "split"
132
132
  post "supplier_confirm"
133
+ post "confirm_item"
133
134
  post "retailer_confirm"
134
135
  end
135
136
  collection do
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.9.6".freeze
3
+ VERSION = "0.9.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.9.6
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-06-29 00:00:00.000000000 Z
10
+ date: 2026-06-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails