ffl_core.api.receive_goods¶
Source: apps/ffl_core/ffl_core/api/receive_goods.py · 6 endpoint(s)
Generated by
make api-docs— do not edit by hand.
create_item¶
POST /api/method/ffl_core.api.receive_goods.create_item
Auth (derived from code): Roles: Stock Manager / System Manager
Quick-create an Item from the Receive Goods page, then return the
same shape as lookup_item so the caller can drop the result straight
into the pending card.
| arg | type | required | default | description |
|---|---|---|---|---|
payload |
— | yes | — | Dict or JSON string. Required: item_code, item_group. Optional: item_name (defaults to item_code), has_serial_no (0), stock_uom (defaults to "Nos"), standard_rate, barcode, uniform_sell_price, is_antique (GCA-exempt marker). |
Returns: Same shape as lookup_item's successful response.
Permissions: Stock Manager / System Manager.
apps/ffl_core/ffl_core/api/receive_goods.py:899
create_receive¶
POST /api/method/ffl_core.api.receive_goods.create_receive
Auth (derived from code): Roles: Stock Manager / System Manager
Build + insert + submit a Purchase Receipt from the page's payload.
payload arrives as a JSON string when called via frappe.call from the
browser; accept dicts too for internal Python callers.
Schema: { "supplier": "ACME-FFL", "source": "RSR", # required — internal procurement channel "acquisition_type": "Purchase", # optional — FastBound bound-book acquisition type "posting_date": "2026-05-05", # optional, defaults to today "posting_time": "14:30:00", # optional, defaults to now "warehouse": "Main - GS", # optional, defaults to company default "notes": "...", # optional "items": [ {"item_code": "X", "qty": 100, "rate": 0.50, "serials": [], "service_need": 0}, {"item_code": "FIREARM-A", "qty": 1, "rate": 500, "serials": ["A001"], "service_need": 1, "manufacturer": "Glock", "model_name": "19", "firearm_type": "Pistol", "caliber": "9mm", "importer": ""}, {"item_code": "FIREARM-B", "qty": 1, "rate": 0, "serials": ["B001"], "zero_cost_confirmed": 1, "zero_cost_reason": "Supplier gift", "zero_cost_note": "", "manufacturer": "...", "model_name": "..."} ] }
Any line may carry storage_location (a Storage Location name): where the
units are put in the store. A firearm line with several serials fills that slot and
the next free ones in the same zone; serial_locations ({serial: location})
overrides it per gun. A line with no location lands in "unassigned" on the
Storage Locations page. Ignored for a customer-custody receive.
rate is REQUIRED on every line except a customer-custody receipt
(is_ffl_transfer, forced to 0 here) and a consignor's stock
(acquisition_type="Consignment", legitimately $0). A missing rate and a
rate of 0 are NOT the same thing and neither is accepted silently: an
acquisition that really was free must say so with zero_cost_confirmed: 1
plus a zero_cost_reason from ffl_core.setup.zero_cost.ZERO_COST_REASONS
("Supplier gift" / "Promotional item" / "Warranty replacement" / "Sample" /
"Other"), and "Other" additionally requires a free-text zero_cost_note.
The trio lands on the Purchase Receipt Item (ffl_-prefixed) and, for
firearms, on each Serial No.
Validation here is minimal — server-side hooks (validate, on_submit) enforce the FFL gate + Used Firearm qty=1 + Acquisition creation.
A purchase from a private seller (acquisition_source "Individual")
that costs anything says how the seller was paid: seller_payment_method
(Cash / Zelle / Check / ACH) and, unless Cash, seller_payment_reference
(check number, Zelle confirmation, ACH reference). Whether and how much is
paid is one decision (cash_drawer.seller_payment_at_receipt), the same
one seller_payment_preview gives the page before Submit. The payment is
booked in the receive's transaction BEFORE the bound-book push, and the
drawer lock is taken first, before any stock is written, with a bounded
wait (the same lock order as a count, so the two never deadlock): nothing
that can fail runs after FastBound has the acquisition, and a push that
fails rolls the payment back with the receipt. The amount booked must be
the amount the dialog showed, or the receive is refused before the push. Dr Stock Received But Not Billed / Cr Cash, or the bank account,
dated today (cash_drawer.record_goods_payout). It covers every line, the guns
included. Which receipts pay: cash_drawer.receipt_pays_seller (the
acquisition type blank, "Purchase" or "Individual"); a Consignment,
Gunsmithing or transfer receipt, a customer-custody one and a dealer
purchase pay nobody here, and a method sent for one is ignored.
| arg | type | required | default | description |
|---|---|---|---|---|
payload |
— | yes | — | See Schema above — dict or JSON string. |
before_push |
— | no | None |
Internal callers only: a callable run in the receive's transaction just before the bound-book push (a whitelisted call's arguments are never callable). |
Returns: {ok: True, name:
Raises: ValidationError: Payload errors or PR submit failures.
Permissions: Stock Manager / System Manager.
apps/ffl_core/ffl_core/api/receive_goods.py:132
get_receive_sources¶
POST /api/method/ffl_core.api.receive_goods.get_receive_sources
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Source dropdown values for Receive Goods + FFL Acquisition + Purchase
Receipt.
Admin-edited in FFL Settings → Receive Sources (one per line).
Returns: List of source strings, in configured order.
apps/ffl_core/ffl_core/api/receive_goods.py:1091
lookup_item¶
POST /api/method/ffl_core.api.receive_goods.lookup_item
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Resolve a barcode or item code → item info dict.
Tries the Item Barcode child table first, then Item code.
| arg | type | required | default | description |
|---|---|---|---|---|
scan |
string | yes | — | Scanned barcode or typed item code. |
Returns: {found: bool, item_code, item_name, item_group, has_serial_no, is_firearm, is_antique, antique_locked, last_rate, stock_uom, standard_rate, uniform_sell_price, dealer_price, ...} plus, for firearms, the firearm detail fields (manufacturer, model_name, caliber, firearm_type, year_made — importer is never returned: it is a per-gun marking stated at receive, not an Item default).
apps/ffl_core/ffl_core/api/receive_goods.py:54
search_items¶
POST /api/method/ffl_core.api.receive_goods.search_items
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Typeahead search across Item.barcode, Item.item_code (SKU), Item.item_name.
Ordering: exact barcode / item_code matches first, then LIKE matches ranked by item_name. Disabled items excluded.
| arg | type | required | default | description |
|---|---|---|---|---|
query |
string | yes | — | Substring to match (blank returns []). |
limit |
integer | no | 10 |
Row cap, clamped to 1–50 (default 10). |
Returns: Up to limit rows with the same shape as lookup_item's successful response (minus the found flag), so the JS can hand a picked row directly to the pending-card builder.
apps/ffl_core/ffl_core/api/receive_goods.py:809
seller_payment_preview¶
POST /api/method/ffl_core.api.receive_goods.seller_payment_preview
Auth (derived from code): Roles: Stock Manager / System Manager
What Submit will pay the private seller, before anything is written: the Pay the seller dialog shows exactly
what the receipt will book (the same rule and amount as create_receive).
| arg | type | required | default | description |
|---|---|---|---|---|
payload |
— | yes | — | The create_receive payload (dict or JSON string); only the acquisition source / type, the transfer markers and the lines are read. |
Returns: {pays, amount, methods}; pays is false when nobody is paid at receipt (a dealer, Consignment, Gunsmithing or transfer receipt, or nothing costs anything); methods are the ways a seller can be paid.
apps/ffl_core/ffl_core/api/receive_goods.py:743