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.
B2B Order Documents (Documents Area + Logistics Prints)
Status: Draft — design finalized 2026-08-30, nothing built
Target: Spree 6.1
Depends on: Customer PO Numbers (6.0-b2b-customer-po-numbers.md — po_document, the first order attachment), B2B Wholesale Shipping (6.0-b2b-wholesale-shipping.md — freight summary feeds the packing list), B2B Payment Terms (6.0-6.1-b2b-payment-terms.md — schedule + bank reference feed the payment sheet)
Author: Damian + Claude
Last updated: 2026-08-30
Tracking: Linear V-3613 · GitHub spree/spree#14609
Summary
A B2B order accumulates paperwork — the buyer's PO, the quotation, packing lists, shipping documents — and today the only place it can live is email threads. This plan adds an order Documents area (uploaded files, private storage, per-document customer visibility, listed in the buyer's order view) and extends the dashboard's existing client-side print path with two generated documents the data already supports: a carton-level packing list (units / cartons / pallets / gross weight / CBM from the freight summary, plus PO and order numbers) and a payment-instructions sheet (order + PO references, terms snapshot, amount due now, bank transfer details + payment reference). Real invoices — numbered proforma and commercial documents with PDF generation and legal numbering — are deliberately NOT here: they are the Enterprise terms/invoicing product (tier decided 2026-08-30; no OSS competitor generates them either, and legal numbering is exactly what the document-numbers plan says core never promises).
Key Decisions (do not deviate without discussion)
Spree::OrderDocumentis an uploaded-file row, not a generation pipeline:order_id,label,customer_visible(default false), private-storage attachment (spoofing-protected, the seller-submission/tax-certificate precedent),uploaded_by(staff or the customer — buyers can add their own paperwork through the account order view). The plannedpo_documentkeeps its dedicated slot (it has semantics — the requiredness check); the Documents area lists it alongside the generic rows.- Generated documents stay client-side HTML prints in 6.1, extending the shipped packing-slip pattern (deliberately a print window, not an admin route; everything needed is already loaded on the order screen). The packing list adds the carton/pallet/CBM block from the frozen freight summary; the payment-instructions sheet renders the terms schedule + bank preferences + payment reference. Neither claims to be an invoice, carries no invoice number, and creates no stored artifact.
- No PDF stack in core. The day server-side rendering is needed, it arrives with the Enterprise invoicing product; OSS prints and OSS uploads never grow a PDF dependency.
- Customer visibility is per document, default private — internal paperwork stays internal; the buyer's order view lists visible documents with expiring signed URLs (the private-storage read pattern).
Design Details
class Spree::OrderDocument < Spree.base_class
belongs_to :order, class_name: 'Spree::Order'
belongs_to :uploaded_by, polymorphic: true, optional: true
has_one_attached :file, service: Spree.private_storage_service_name
validates :label, presence: true
# customer_visible boolean, default false, null: false
end
- Admin API: nested
/admin/orders/:id/documentsCRUD (direct upload via signed blob); store API: documents index on the account order view (visible only) + create (buyer uploads, always visible to themselves, flagged as buyer-supplied for staff). - Dashboard: a Documents card on the order page (upload, visibility toggle, download, delete-with-confirm); print actions beside the existing packing slip.
- Storefront: documents list on the order page — completing the buyer
view: stage + expected date (
6.1-order-stages.md), payment schedule (6.0-6.1-b2b-payment-terms.md), shipment/freight summary, documents.
Migration Path
- Schema + model + admin nested CRUD + dashboard card.
- Store surfaces (list + buyer upload).
- The two prints (packing list block, payment sheet).
Nothing to migrate.
Constraints on Current Work
- Order-facing files go through
OrderDocumentor a dedicated semantic slot (likepo_document) — never loose attachments on other models. - No invoice vocabulary in OSS — no model, number, or document may be called an invoice; the payment sheet is "payment instructions".
- Prints render
po_numberand the payment reference when present (the PO plan's document constraint applies).
Open Questions
None for this scope. (Auto-attaching generated prints as stored documents is deliberately not done — a print is a view of live data; a stored artifact is an invoicing feature.)
References
- Merchant feedback, 2026-08 (documents area; proforma/packing list/commercial invoice; customer visibility).
- Print precedent:
packages/dashboard/src/lib/packing-slip.ts. - Attachment precedents:
Spree::TaxExemptionCertificate#document,Spree::SellerRequirementSubmission#file. - Enterprise invoicing:
ee/docs/plans/b2b-companies.mdroadmap item 1.