Orders & fulfilment
Order Editing
Indicative price, not an offer: €14/mo; audit trail for regulatory compliance
Generated from docs/plan/paid/order-editing/PLAN.md in the AstroBaaS repository. Nothing described below is implemented — it is the written plan for it.
A system for merchants to edit orders before fulfillment, with automatic tax and shipping recalculation, refund/charge handling, and audit trail.
The problem
Customers email to change orders before shipment; manual edits are slow and error-prone. Merchants need a way to add/remove line items and recalculate totals quickly.
What it does
- Edit order line items (quantity, price, product) before fulfillment begins
- Recalculate tax and shipping on line-item change
- Handle refunds if customer removes items (partial refund)
- Handle charges if customer adds items (increment order total, request payment)
- Audit trail: what changed, who changed it, when
- Email customer to confirm change and new total
- Prevent edits after shipment (fulfillment-shipping-labels module marks order as shipped)
- Revert edit (undo last change) if error made within 5 minutes
What it deliberately does NOT do
Each boundary carries its reason. A boundary without a reason gets crossed by the next person who reads this.
- Address change after shipment — cannot change shipping address post-fulfillment. Reason: carrier/3PL already has label.
- Payment reversal — core does not refund payment directly; payment gateway owns reversal. Reason: PCI scope.
- Recalc discounts — manual discounts do not recalc on line-item change. Reason: complex business logic; paid feature.
Data model
New tables: OrderEdit {id, orderId, userId (admin who made edit), action (‘line_item_added’|‘line_item_removed’|‘line_item_quantity_changed’|‘line_item_price_changed’), oldValue, newValue, taxRecalc, shippingRecalc, refundAmount (if negative edit), chargeAmount (if positive edit), createdAt, revertedAt (if reverted)}. No migration.
API
- POST /api/orders/:id/edits
- GET /api/orders/:id/edits
- POST /api/orders/:id/edits/:editId/revert
Every route added here must also appear in src/pages/openapi.json.ts — a test
fails the build if it does not.
Admin
Order edit button: select line item, edit quantity/price, preview new total, confirm. Edit history: show all changes, option to revert. Email confirmation: auto-send to customer with change summary.
The seam — why this is paid
Core owns: order structure, tax/shipping recalc interface. Paid owns: edit workflow, payment reversal coordination, approval (if required).
Support commitment: tax recalculation on line-item changes, refund flow reversal
Dependencies
- Order infrastructure
- fulfillment-shipping-labels (to prevent edits post-fulfillment)
- Tax system (recalc)
- Email system
Acceptance checks
Each of these must be able to fail. Before claiming this is done, break the code deliberately and watch each one go red.
- Editing order line-item quantity from 2 to 1 recalculates tax and shipping; order total decreases
- If edit creates negative balance (refund), OrderEdit.refundAmount is populated and email indicates refund will be issued
- If edit increases total, OrderEdit.chargeAmount is populated and email requests payment for difference
- Revert within 5 min undoes last edit; order returns to pre-edit state
- Prevent edit: if order status is ‘shipped’ or ‘delivered’, endpoint returns {error: ‘order_already_fulfilled’}
- Audit log records who made edit, what changed, newValue, and system recalculations
Risks
Double-charge: customer charged twice if edit UI submitted twice; mitigation: idempotent endpoint or at-most-once semantics. Timing race: fulfillment staff ships order while admin edits; mitigation: order-level lock.
Commercial context
| Suggested price | €14/mo; audit trail for regulatory compliance |
| Rival anchor | Shopify: free (core) in 2.0+; Magento: free (admin) |
The anchor is what the nearest equivalent charges on Shopify or Magento today. It is context for a pricing decision, not the decision.
Generated from the commerce plan. See docs/COMMERCE-PLAN.md for the full
catalogue and ../../AI-GUIDE.md for how to work on this repository.