Skip to main content

Warehouses

Overview​

Warehouses, the users allowed to work in them, bin locations, and channel/courier facility mappings.

Code map​

PiecePath
Warehousesrc/modules/operations/warehouse
Connection Locationssrc/modules/operations/warehouse/services/connection-locations.service.ts
Binssrc/modules/operations/bin-location
Schema30-warehouse.prisma, 21-channel.prisma, 22-partner.prisma
GuardWarehouseGuard in src/common/request

Entities: Warehouse, UserWarehouse, BinLocation, WarehouseCourierLocation, WarehouseChannelLocation.

Enums observed: WarehouseType, StockOwnership, BinLocationType, BinLocationStatus, VelocityClass.

Business rules​

Implementation behavior

WarehouseGuard confines an authenticated user to warehouses allowed by membership. x-warehouse-id and warehouse ids in the route, query, or body can only narrow that set. The guard returns true when there is no user.

Status

Enforced by the guard.

Commercial meaning of StockOwnership (seller versus tenant) is unknown.

Facility Location Mappings (Warehouse-Centric Integration)​

PointNXT connects physical warehouses to sales channels and courier accounts through mapping tables. A location or pickup id is never read from channel or courier config: the mapping is the only binding.

1. Warehouse Channels (WarehouseChannelLocation)​

Links a warehouse to a sales channel:

  • externalLocationId: The channel's own location for this warehouse (a Shopify location, a Flipkart seller hub). Channels that hold one stock figure per product (Amazon, WooCommerce, BigCommerce, WhatsApp) have no locations and store an empty id.
  • contributesStock: The warehouse's sellable stock counts towards what the channel is told, and orders can be routed here automatically. Off keeps the warehouse linked without selling from it.
  • isDefault: The channel's primary location. Routing tries it first, before the tenant's preferred warehouse. Each channel with mappings keeps exactly one.

Rules, enforced by every API that writes these rows (channelLocationIdsFor in src/common/integrations/channel-locations.ts):

  • A channel supports locations when its inventory service implements listRemoteLocations or declares entersLocationsManually (inventorySupportsLocations); the mapping APIs read the same answer from channelSupportsLocations, held in step by test/integrations/channel-locations.contract.spec.ts.
  • Flipkart declares entersLocationsManually: its Seller API has no endpoint that lists a seller's locations (the id is issued at onboarding), so the seller types the location id. The one exception is the OAuth connect: when Flipkart names a hub in the redirect and the tenant has one owned warehouse, that hub is bound automatically.
  • For those channels each mapped warehouse needs its own location id; two warehouses cannot share one.
  • Stock is published per location for channels with locations, split by each warehouse's sellable stock. Every other channel gets one pooled figure from its mapped warehouses.
  • An order the channel assigned to a location (a Flipkart shipment's hub, the one store location Shopify assigned) is pinned at import to the warehouse mapped to that location, when exactly one active owned warehouse is. Channel-fulfilled orders are never pinned.
  • With no mappings at all, a channel publishes pooled stock and routes to any owned active warehouse.

2. Warehouse Couriers (WarehouseCourierLocation)​

Links a warehouse to a courier account:

  • externalLocationId: The pickup id the courier books by (Shiprocket pickup nickname, Delhivery warehouse name, Shipway numeric warehouse id, iThink pickup address id, Blue Dart origin area). Couriers that book from the warehouse address (DTDC, Porter, FedEx, Stamps, Amazon Shipping) store an empty id.
  • config: Unused for now. Couriers book by externalLocationId alone, and saving a mapping clears it.
  • isActive: Pickups paused when false, keeping the pickup id.
  • isDefault: The preferred courier at this warehouse, one per warehouse. This is the only place the warehouse preference is kept; Warehouse.preferredCourierId is no longer read or written.
  • supportsForward / supportsReverse: Reverse pickups are not booked through couriers yet, so the admin offers no returns switch and saves keep outbound on.

What each courier needs is declared in src/common/integrations/courier-pickup.ts and enforced on save (required, numeric where stated). See Couriers for allocation and pickup lookup.

Complementary Management Viewpoints​

Location mappings can be managed from two operational perspectives:

  1. Warehouse-Centric View (Operations Lead):
    • Navigated via Warehouse Settings (/warehouses/:id/settings), Channels and Couriers tabs.
    • APIs:
      • GET / PUT /v1/operations/warehouse/:id/channel-locations
      • GET / PUT /v1/operations/warehouse/:id/courier-locations
  2. Connection-Centric View (Channel / Logistics Lead):
    • Navigated via the channel or courier's Locations tab in the Integration Hub. The channel tab also sets where customer returns go (Channel.defaultReturnWarehouseId, owned active warehouses only).
    • APIs (platform admins may pass tenantId):
      • GET / PUT /v1/operations/warehouse-connections/channels/:channelId/locations
      • GET / PUT /v1/operations/warehouse-connections/couriers/:courierId/locations
      • GET /v1/commerce/marketplace/channels/:channelId/remote-locations returns { supportsLocations, locations }, read live from the channel. A channel that cannot list its locations returns { supportsLocations: true, manualEntry: true, locations: [] }, and the admin shows a text field for the id.

Both write the same rows under the same rules; each save replaces the caller's list, and courier rows are only written when they change, so updatedAt marks when a pickup's settings last changed.

API surface​

Warehouse, connection-locations, and bin-location controllers. The floor app selects a warehouse inside the confined set. It cannot grant itself another warehouse by sending a header.

Workflows​

Fulfillment, Inventory, Shipping, Couriers, Channels, Authentication.