ffl_integrations.distributor.api¶
Source: apps/ffl_integrations/ffl_integrations/distributor/api.py · 14 endpoint(s)
Generated by
make api-docs— do not edit by hand.
cancel_order¶
POST /api/method/ffl_integrations.distributor.api.cancel_order
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console
Cancel a Distributor Order here (alerts ops when it is still live at the house).
Cancelling never reaches the distributor, so an order that is live there
(Placed+) has to be cancelled with the house by phone or email.
Left unconfirmed, ops are alerted to arrange that; confirmed records
that the house has already agreed and skips the alert.
| arg | type | required | default | description |
|---|---|---|---|---|
do_name |
string | yes | — | Distributor Order name. |
reason |
string | null | no | None |
Optional reason, stored as hold_reason. |
confirmed |
— | no | False |
The distributor has confirmed the cancellation (phone / email); no ops alert, and a standard reason when none is given. |
Returns: {"name": ..., "status": "Cancelled"}.
Permissions: Distributor order/console roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:1130
catalog_by_upc¶
POST /api/method/ffl_integrations.distributor.api.catalog_by_upc
Auth (derived from code): Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).
The enabled houses' catalog rows for one UPC — the Receive Goods page's
fallback when a scanned barcode matches no Item, so the Item can be created from the catalog instead of typed.
| arg | type | required | default | description |
|---|---|---|---|---|
upc |
string | yes | — | The scanned barcode. |
Returns: [{distributor, sku, upc, item_name, manufacturer, model, cost, map, msrp, qty, ffl_required, department, image_url}] — one row per house that lists it; a house whose catalog is down is simply absent.
Permissions: Open read for any signed-in desk user (same as search).
apps/ffl_integrations/ffl_integrations/distributor/api.py:224
check_availability¶
POST /api/method/ffl_integrations.distributor.api.check_availability
Auth (derived from code): Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).
Live qty/price second-confirm before a Draft order is placed.
Open read (no only_for) by design — see search; the console depends on it
and the counter uses it. Do not add a gate.
| arg | type | required | default | description |
|---|---|---|---|---|
lines |
— | yes | — | [{sku, qty}] — list or JSON string. |
distributor |
string | null | no | None |
Optional Distributor name. |
Returns: Provider availability rows (live qty/price per line).
Permissions: Open by design — any authenticated desk user; see search.
apps/ffl_integrations/ffl_integrations/distributor/api.py:316
confirm_order¶
POST /api/method/ffl_integrations.distributor.api.confirm_order
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console
Confirm a Draft Distributor Order: Draft → Queued + enqueue placement.
Human confirmation (the v1 queue gate); the placement worker is idempotent. A counter-sourced drop-ship DO must be fully paid first (placement_payment_block); a ship-to-store leg may be placed on a deposit. A web order's DO is refused once the Woo order is no longer paid.
| arg | type | required | default | description |
|---|---|---|---|---|
do_name |
string | yes | — | Distributor Order name. |
Returns: {"name": ..., "status": "Queued"}.
Permissions: Distributor order/console roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:1093
create_orders¶
POST /api/method/ffl_integrations.distributor.api.create_orders
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager
Plan + create the Draft Distributor Order(s) for a cart.
plan_fulfillment may split one cart into several orders (no
firearm/accessory mixing / H4 >400) — each becomes its own Draft DO. A
classification divergence raises (order held for a human). Never
places anything: v1 is a human-confirmed queue.
| arg | type | required | default | description |
|---|---|---|---|---|
distributor |
string | yes | — | Distributor name. |
lines |
— | yes | — | Cart lines [{sku/item_code, qty, ...}] — list or JSON string. |
ship_context |
— | no | None |
Optional {mode: "stocking"|"to_store"|"direct"|"fds", ...} — the lane to order on (see distributor/lanes.py); defaults to stocking. |
Returns: [{name, order_type, account, line_count}] — one per created Draft DO.
Permissions: Distributor order roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:778
ensure_dropship_item¶
POST /api/method/ffl_integrations.distributor.api.ensure_dropship_item
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Counter Create Order seam: make sure this catalog SKU has a local Item that
can carry a drop-ship line — dual-source guard → idempotent promote →
dropship_distributor stamp — WITHOUT a web listing (that stays Flow B's
create_listing). Closes the gap where an un-promoted SKU produced a
counter line with no item_code that _validate_items then refused.
A WRITE (Item insert + stamp), so unlike search/quote it is role-gated — to the same roles that may ring the counter order itself (manual_order._ROLES). An Item already stamped by ANOTHER distributor is returned as it is, never re-homed: the counter line orders from the house it names, while the stamp keeps driving the web listing, web-order routing and stock publishing.
| arg | type | required | default | description |
|---|---|---|---|---|
sku |
string | yes | — | Distributor SKU (required). |
distributor |
string | null | no | None |
Optional Distributor name; defaults to the resolved primary. |
claim |
— | no | 1 |
1 (default) stamps the Item's dropship_distributor for this house when it has none and no listing holds it (a listed product's stamp is its listing's); 0 only promotes it — a ship-to-store line buys the goods into our own stock and says nothing about who drop-ships the Item on the web. |
Returns: {item_code, item_name, is_firearm, claimed_by} — claimed_by is the house the Item's drop-ship stamp names after the call (empty when nothing claims it).
Permissions: Counter roles (Sales User / Sales Manager / Stock Manager / System Manager).
apps/ffl_integrations/ffl_integrations/distributor/api.py:485
fulfillment_freight¶
POST /api/method/ffl_integrations.distributor.api.fulfillment_freight
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Estimated distributor freight for the Fulfillment planner's CURRENT choice.
The planner re-asks on every selection change. Lines are grouped exactly as the counter hook will order them — by (distributor, lane) and then the provider's own split (firearms and accessories never share an order) — and each resulting order is priced by the provider's freight rules, so a mixed drop-ship + ship-to-store cart is the sum of its real orders. Nothing is read from the catalog: the matrix already sent cost / department / ffl_required, and this is a display estimate (the invoiced freight wins).
| arg | type | required | default | description |
|---|---|---|---|---|
lines |
— | yes | — | [{distributor, mode: "direct"|"to_store", sku, item_code?, qty, cost, department, ffl_required}] — list or JSON string; local lines are simply not sent. |
options |
— | no | None |
Optional {options_key: {signature, adult_signature, insurance}} — the delivery options picked per order (list or JSON string); an order without an entry uses its house's defaults. |
Returns: {"orders": [{distributor, mode, order_type, line_count, merchandise, freight, firearm, options_key, options}], "total": float, "complete": bool} — freight is None (and complete False) for a house that can't estimate; options is None for a house with no delivery options to choose.
Permissions: Counter roles — the planner belongs to Create Order.
apps/ffl_integrations/ffl_integrations/distributor/api.py:741
fulfillment_matrix¶
POST /api/method/ffl_integrations.distributor.api.fulfillment_matrix
Auth (derived from code): Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).
One-shot batch quote for the Create Order Fulfillment planner.
Every line × (local stock + each enabled distributor). Open read (like search/quote). Column-level degradation — one failing house only greys out its own column; the local column and the rest render normally.
| arg | type | required | default | description |
|---|---|---|---|---|
lines |
— | yes | — | [{"item_code": str?, "sku": str?, "upc": str?, "qty": int}] — list or JSON string. A line with only upc (an "API" pick whose house is not chosen yet) resolves per column by UPC. |
Returns: {"columns": [distributor, ...], "rows": [{item_code, sku, qty, local: {in_stock, feasible}, is_firearm, channels: [cell, ...], preselect, preselect_mode}]} — is_firearm is what the server enforces for the line's own Item (None without one); cell = {distributor, sku, cost, store_cost (the per-unit cost shipped to the store: full cases at the house's case price), case_note? (the case-price hint), qty, department, mode: "direct"|"to_store" (the house's default), modes: {direct, to_store: {feasible, reason}}, ffl_required, feasible, reason?} or {distributor, error: True}.
Permissions: Open by design — any authenticated desk user; see search.
apps/ffl_integrations/ffl_integrations/distributor/api.py:567
list_orders¶
POST /api/method/ffl_integrations.distributor.api.list_orders
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager
List Distributor Orders, newest-modified first — every house and every
order type in one list (the Distributor Orders page's tracking tab).
| arg | type | required | default | description |
|---|---|---|---|---|
status |
string | null | no | None |
Optional exact status filter. |
distributor |
string | null | no | None |
Optional Distributor filter. |
limit |
integer | no | 50 |
Row cap (default 50, max 500). |
open_only |
— | no | 0 |
1 = leave out Complete and Cancelled orders. |
order_type |
string | null | no | None |
Optional exact order type (Stocking, Dropship Firearm, ...). |
with_lines |
— | no | 0 |
1 = add each order's lines [{sku, description, wish_qty, invoiced_qty, received_qty, line_status, tracking_numbers, invoices}]. |
Returns: [{name, distributor, order_type, account, account_number, status, hold_status, web_ref, total_cost, placed_at, next_poll_at, receive_status, source_doctype, source_name, creation, last_poll_at, invoiced_freight, error}] — plus lines when asked.
apps/ffl_integrations/ffl_integrations/distributor/api.py:1194
quote¶
POST /api/method/ffl_integrations.distributor.api.quote
Auth (derived from code): Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).
Per-item drop-ship quote for the Create Order panel and the counter
server-side eligibility check.
``fulfillment_mode`` is the RESOLVED judgement (Direct / To Store)
through the canonical chain — consumers judging drop-shippability read IT,
not the raw flags. ``restricted_states`` = states where the distributor's
own restriction feed blocks drop-ship of this SKU — display only, and
NOT the operator's ``Item.restricted_states`` compliance field.
``suggested_price`` is the SAME chain the listing
pipeline prices with (``listing_price.price_for``) — never a second pricing path —
as the COUNTER price: the website's MAP floor does not apply at the counter
so it can sit below the listing's website price. Reads the
provider's LOCAL catalog (no HTTP), so it is cheap enough per keystroke; the
real-time RSR re-confirm stays at placement (place_order_job).
A read — open to any signed-in desk user (like ``search`` / ``check_availability``).
This openness is load-bearing: it is WHY the counter register can quote without
the console role. Do not add only_for here (the one effect is to break
Create Order, with no security gain since catalog data has no PII).
| arg | type | required | default | description |
|---|---|---|---|---|
item_code |
— | no | None |
Local Item code (resolves the distributor stamp when distributor is omitted). |
sku |
— | no | None |
Distributor SKU (either this or item_code must resolve). |
distributor |
— | no | None |
Optional Distributor name. |
Returns: {found, sku, upc, item_code, distributor, cost, map, msrp, suggested_price, qty, restricted_states, fulfillment_mode, dropship_blocked, vendor_approval_required, ffl_required, manufacturer, model, department} — or {found: False, ...} when not in catalog. A site with no distributor catalog answers HTTP 417 (CapabilityOff).
Permissions: Open by design — any authenticated desk user; catalog data carries no PII and the counter panel depends on it.
apps/ffl_integrations/ffl_integrations/distributor/api.py:339
search¶
POST /api/method/ffl_integrations.distributor.api.search
Auth (derived from code): Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).
Typeahead over the resolved provider's catalog (RSR reuses rsr/search.py).
Open read, no only_for: catalog-level data carries no PII, and the console role depends on this openness. Do NOT add a gate here — the only effect would be to break the counter Create Order panel, with no security gain.
Clamped to the service contract (CatalogSearchRequest: q min_length=1,
limit 1..50) — same shape as rsr/search.py's shim — so an empty/blank query
or an out-of-range limit never reaches the transport at all.
| arg | type | required | default | description |
|---|---|---|---|---|
query |
string | yes | — | Search term (blank returns []). |
limit |
integer | no | 10 |
Row cap, clamped to 1–50 (default 10). |
distributor |
string | null | no | None |
Optional Distributor name; defaults to the resolved primary. |
Returns: Catalog rows, each tagged with its distributor provenance.
Permissions: Open read for any signed-in desk user (load-bearing, see above).
apps/ffl_integrations/ffl_integrations/distributor/api.py:187
set_shipping_service¶
POST /api/method/ffl_integrations.distributor.api.set_shipping_service
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console
Choose the carrier service for a Draft Distributor Order.
Only a Draft order may change (Queued and later are at or past the distributor); the code must be one the provider offers for this order.
| arg | type | required | default | description |
|---|---|---|---|---|
do_name |
string | yes | — | Distributor Order name. |
code |
string | yes | — | Service code from shipping_options ('' = the provider's empty-code service, e.g. Sports South Ground Economy). |
Returns: {"name", "shipping_service", "shipping_service_label"}.
Permissions: Distributor order/console roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:1012
shipping_options¶
POST /api/method/ffl_integrations.distributor.api.shipping_options
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console
Carrier services the distributor offers for this order, with the
flat-rate estimate, so the operator can choose before Confirm.
| arg | type | required | default | description |
|---|---|---|---|---|
do_name |
string | yes | — | Distributor Order name. |
Returns: [{code, label, estimate, default, selected}] — empty when the provider decides shipping itself.
Permissions: Distributor order/console roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:987
transition_order¶
POST /api/method/ffl_integrations.distributor.api.transition_order
Auth (derived from code): Roles: Purchase Manager / Purchase User / Stock Manager / System Manager
Generic ops state transition for a Distributor Order.
The DO state machine still enforces transition legality.
| arg | type | required | default | description |
|---|---|---|---|---|
do_name |
string | yes | — | Distributor Order name. |
to_status |
string | yes | — | Target status. |
Returns: {"name": ..., "status":
Permissions: Distributor order roles.
apps/ffl_integrations/ffl_integrations/distributor/api.py:1171