ffl_core.firearm¶
Source: apps/ffl_core/ffl_core/firearm.py · 7 endpoint(s)
Generated by
make api-docs— do not edit by hand.
available_serials_for_items¶
POST /api/method/ffl_core.firearm.available_serials_for_items
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Return {item_code: [in-stock serial, ...]} so the POS 4473 dialog can offer
a pick-list of real on-hand serials instead of free-typing one.
Every firearm has has_serial_no=1 and its serials live in the Serial No table — Item.firearm_serial fallback was removed when the Used Firearm path was unified. Codes with nothing on hand map to [] so the caller can warn + block the sale.
| arg | type | required | default | description |
|---|---|---|---|---|
item_codes |
array | yes | — | Item codes — list or JSON string. |
exclude_unavailable |
int | bool | no | True |
current_invoice |
string | null | no | None |
Optional POS Invoice docname — the serial already parked on THIS invoice's own line stays offered (incident a past invoice, see _pos_picker_excluded_serials). The POS 4473 dialog passes it so the serial on the line the cashier is completing doesn't vanish from its own dropdown. On a web order's in-store pickup ticket, the gun that order reserved stays offered too. |
customer |
string | null | no | None |
Optional buyer — a gun held for this customer's CRM deal stays offered. |
Returns: {item_code: [in-stock serial, ...]}.
apps/ffl_core/ffl_core/firearm.py:642
available_serials_with_prices¶
POST /api/method/ffl_core.firearm.available_serials_with_prices
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Like available_serials_for_items but enriches each serial with sell_price
and purchase_rate (cost), sorted by sell_price ascending so the POS picks the cheapest in-stock unit by default. Used by the POS Item Details serial picker to render a price-first dropdown.
| arg | type | required | default | description |
|---|---|---|---|---|
item_codes |
array | yes | — | Item codes — list or JSON string. |
exclude_unavailable |
int | bool | no | True |
current_invoice |
string | null | no | None |
Optional POS Invoice docname — the serial already parked on THIS invoice's own line stays offered (incident a past invoice); the Item-Details picker passes it so editing a firearm line doesn't drop its own serial from the dropdown. |
customer |
string | null | no | None |
Optional buyer — a gun held for this customer's CRM deal stays offered, marked held_for_customer. |
Returns: {item_code: [{"serial", "sell_price", "purchase_rate", "held_for_customer"?}, ...]}, sorted by sell_price ascending.
apps/ffl_core/ffl_core/firearm.py:1385
firearm_items_in¶
POST /api/method/ffl_core.firearm.firearm_items_in
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Return the subset of item_codes that are REGULATED firearms (antiques excluded).
Called from POS JS to decide whether to surface the 4473 button / whether the submit gate applies. Antique firearms (GCA-exempt) need no 4473, so they are filtered out here — an antique-only cart looks like an accessories cart to the POS and completes without the charge-then-hold flow.
| arg | type | required | default | description |
|---|---|---|---|---|
item_codes |
array | yes | — | Item codes — a list or a JSON string (Frappe transports list args as JSON over the wire). |
Returns: The subset of item_codes that are regulated firearms.
apps/ffl_core/ffl_core/firearm.py:425
get_transfer_config¶
POST /api/method/ffl_core.firearm.get_transfer_config
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
POS transfer-dialog config: the fee item + default per-firearm fee.
Lazily creates the TRANSFER-FEE service item on first use — by the time the POS is live the site's UOM/Item-Group masters exist, unlike at install/migrate time (a fresh install runs hooks/patches before ERPNext's setup wizard). Mirrors receive_goods.get_receive_sources for reading FFL Settings.
Returns: {"fee_item":
apps/ffl_core/ffl_core/firearm.py:1527
in_stock_firearm_serials¶
POST /api/method/ffl_core.firearm.in_stock_firearm_serials
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Every in-stock firearm serial, for the POS customer-transfer picker.
The two cart-driven pickers (available_serials_for_items, firearm_items_in) need item_codes up front; a transfer starts before any gun is in the cart, so this returns the whole in-stock firearm set instead. Price is informational (picker label) — reuses the uniform/per-serial logic of available_serials_with_prices; the transfer always adds the gun at $0.
Custody guns are deliberately NOT excluded here (exclude_custody=False), unlike in the two SALE pickers. This dialog is how a customer's gun goes home: hiding custody guns from it would strand every gun the custody warehouse receives, which is the opposite of the point.
| arg | type | required | default | description |
|---|---|---|---|---|
exclude_unavailable |
int | bool | no | True |
customer |
string | null | no | None |
Optional transferee — a gun held for this customer's CRM deal stays offered. |
Returns: [{serial, item_code, item_name, sell_price}], ordered item then serial.
apps/ffl_core/ffl_core/firearm.py:1586
pos_pricing_summary¶
POST /api/method/ffl_core.firearm.pos_pricing_summary
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Per-item POS pricing summary — the single data source for the POS card
price range, the add-to-cart rate seed, the picker's auto-pick decision and the checkout gate.
| arg | type | required | default | description |
|---|---|---|---|---|
item_codes |
array | yes | — | Item codes — list or JSON string. |
Returns: {code: {"is_firearm": bool, "uniform": 0|1, "n":
apps/ffl_core/ffl_core/firearm.py:1479
toggle_serial_service_need¶
POST /api/method/ffl_core.firearm.toggle_serial_service_need
Auth (derived from code): Requires write permission on Serial No (Frappe DocType permission check).
Flip Serial No.needs_service AND keep the gunsmith ToDo queue in sync.
Used by the Service Needed pill on the Item form's Serial Numbers tab. Goes through this single helper (instead of raw db.set_value on the client) so the ToDo create/close stays glued to the flag — toggling on creates a ToDo, toggling off closes the matching Open ones.
Permission gate: the helpers below elevate via flags.ignore_permissions / raw db.set_value to bypass ToDo/Serial No DocPerms (managers vs cashiers). Without this gate, any logged-in user could flip needs_service on any serial — including silently closing a gunsmith's Open ToDo queue. Restrict to roles that already own Serial No writes.
| arg | type | required | default | description |
|---|---|---|---|---|
serial |
string | yes | — | Serial No name. |
value |
int | str | yes | — |
Returns: {"ok": True, "needs_service": 0|1}.
Permissions: Frappe write permission on Serial No (a DocType permission check, not a fixed role list — whichever roles carry Serial No write).
apps/ffl_core/ffl_core/firearm.py:739