Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fix: orders export leaves out draft orders (#14732)

Damian Legawiec62600e5db4f0
diff --git a/spree/core/app/models/spree/export.rb b/spree/core/app/models/spree/export.rb
index b75a77b24c..7abe33d96d 100644
--- a/spree/core/app/models/spree/export.rb
+++ b/spree/core/app/models/spree/export.rb
@@ -192,12 +192,13 @@ module Spree
raise SellerScopeUnavailable, model_class unless model_class.respond_to?(:for_seller)
scope = scope.for_seller(seller)
- # A draft is either a checkout in flight or the operator's working
- # document, and is not this seller's sale — the same exclusion every
- # endpoint on the seller branch applies.
- scope = scope.not_drafts if model_class.respond_to?(:not_drafts)
end
+ # A draft is either a checkout in flight or the operator's working
+ # document, not a sale — the orders list and every seller endpoint leave
+ # drafts out too.
+ scope = scope.not_drafts if model_class.respond_to?(:not_drafts)
+
# A staff-created export only contains what its creator may read; a
# userless export (console, system jobs) is unfiltered.
scope = scope.accessible_by(current_ability) if user.present?
diff --git a/spree/core/spec/models/spree/export_spec.rb b/spree/core/spec/models/spree/export_spec.rb
index 2fa0a83631..1df6316d00 100644
--- a/spree/core/spec/models/spree/export_spec.rb
+++ b/spree/core/spec/models/spree/export_spec.rb
@@ -189,6 +189,12 @@ RSpec.describe Spree::Export, :job, type: :model do
it 'spans the store' do
expect(export.scope).to include(sellers_order)
end
+
+ it 'leaves out drafts' do
+ draft = create(:order, store: store, status: 'draft', cart: nil)
+
+ expect(export.scope).not_to include(draft)
+ end
end
end