feat: add partial shipment support (Phase 3)
- Add shipped_quantity field to OrderItem for tracking partial fulfillment
- Add partially_shipped order status for orders with partial shipments
- Add fulfill_item method for shipping individual items with quantities
- Add get_shipment_status method for detailed shipment tracking
- Add vendor API endpoints for partial shipment operations:
- GET /orders/{id}/shipment-status - Get item-level shipment status
- POST /orders/{id}/items/{item_id}/ship - Ship specific item quantity
- Automatic status updates: partially_shipped when some items shipped,
shipped when all items fully shipped
- Migration to add shipped_quantity column with upgrade for existing data
- Update documentation with partial shipment usage examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# alembic/versions/p4d5e6f7a8b9_add_shipped_quantity_to_order_items.py
|
||||
"""Add shipped_quantity to order_items for partial shipments.
|
||||
|
||||
Revision ID: p4d5e6f7a8b9
|
||||
Revises: o3c4d5e6f7a8
|
||||
Create Date: 2026-01-01 12:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'p4d5e6f7a8b9'
|
||||
down_revision: Union[str, None] = 'o3c4d5e6f7a8'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add shipped_quantity column to order_items
|
||||
op.add_column(
|
||||
'order_items',
|
||||
sa.Column('shipped_quantity', sa.Integer(), nullable=False, server_default='0')
|
||||
)
|
||||
|
||||
# Set shipped_quantity = quantity for already fulfilled items
|
||||
# This handles existing data where inventory_fulfilled is True
|
||||
op.execute("""
|
||||
UPDATE order_items
|
||||
SET shipped_quantity = quantity
|
||||
WHERE inventory_fulfilled = 1
|
||||
""")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column('order_items', 'shipped_quantity')
|
||||
Reference in New Issue
Block a user