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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
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.rbindex b75a77b24c..7abe33d96d 100644--- a/spree/core/app/models/spree/export.rb+++ b/spree/core/app/models/spree/export.rb@@ -192,12 +192,13 @@ module Spreeraise 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.rbindex 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 doit 'spans the store' doexpect(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)+ endendend