ffl_integrations.fastbound.importer¶
Source: apps/ffl_integrations/ffl_integrations/fastbound/importer.py · 3 endpoint(s)
Generated by
make api-docs— do not edit by hand.
import_bound_book¶
POST /api/method/ffl_integrations.fastbound.importer.import_bound_book
Auth (derived from code): Roles: System Manager
Import / re-sync the FastBound bound book into ERPNext.
Re-running is a SYNC: already-imported guns (matched by FastBound id) are re-synced
from FastBound, which stays authoritative. A corrected maker/importer re-stamps the
Serial No; a corrected serial renames it (stock + A&D follow); a corrected
model/caliber re-keys the gun onto the right Item (reverse + re-create). Every
structural fix is listed in corrected; a gun that can't be safely auto-moved
(sold/transferred — not a clean in-stock import) is listed in regroup_needed.
| arg | type | required | default | description |
|---|---|---|---|---|
page_size |
integer | no | 100 |
FastBound page size per fetch (default 100). |
dry_run |
integer | no | 0 |
1 writes nothing and returns a projected map (item_code → count / makers / serials) to preview the grouping before committing. |
commit_each |
integer | no | 1 |
1 (default, production) commits after each successful item so a crash mid-import doesn't lose work; 0 (tests) relies on the caller to manage transactions. |
aggregate_by |
string | no | AGGREGATE_AUTO |
How FB items group into ERPNext Items — "auto" (default): SKU → UPC → MPN → model-slug → fb_id fallback; "model": the model+caliber slug ONLY — SKU/UPC/MPN and manufacturer are ignored — so the same model from different manufacturers/importers (surplus M1 Garands, Mausers, …) folds into one Item; each gun's true maker + importer is stamped on its Serial No. Spelling variants are canonicalised (see fastbound.normalize). |
skip_disposed |
integer | no | 1 |
1 (default) imports only CURRENT INVENTORY — guns FastBound marks disposed (sold) or deleted are skipped (the importer creates acquisitions + receipts, not dispositions, so importing a sold gun would wrongly re-stock it). Pass 0 to import the entire historical book. Guns the book records with no serial ("NONE MARKED", "NSN", ...) or with the same serial as another in-stock item are each imported as their own gun under a tagged Serial No (" |
cutover_date |
string | null | no | None |
The day the bound book's inventory is counted as of (default today). Each new gun posts as an opening entry on it: stock debited, the company's Temporary Opening account credited. A future, frozen or closed date is refused. |
Returns: Import stats dict (created/synced/corrected/regroup_needed counts; plus projected on a dry run) and duplicate_groups: [{ledger_serial, no_serial, items: [{fastbound_id, itemNumber, serial, manufacturer, model, caliber}]}] — the guns that get tagged keys, to review first.
apps/ffl_integrations/ffl_integrations/fastbound/importer.py:101
reassign_serial_to_item¶
POST /api/method/ffl_integrations.fastbound.importer.reassign_serial_to_item
Auth (derived from code): Requires write permission on Serial No (Frappe DocType permission check).
Move one in-stock firearm serial from its current Item to target_item,
keeping the SAME Serial No and FFL Acquisition records — so the gun's price, photos, condition, maker/importer/model/caliber, A&D history and FastBound linkage all survive (nothing is deleted, so nothing can be dropped).
ERPNext ties a serial to one Item, so the stock moves with two ledger legs:
issue the serial out of the old Item, flip the serial's item_code, then receive
it into the target. The A&D record's item is re-pointed in place. FastBound is
NOT touched — reassign is a POS-internal re-bucketing; the bound book only changes
on an explicit serial edit. A per-gun WooCommerce listing, where the gun has one,
IS delisted: it belonged to the old Item, and leaving it live sells the same rifle
twice. Whitelisted for the Serial No form's "Reassign Item" action, for resolving
the sync's regroup_needed list, and for the Woo webhook's declared cross-Item
pick (ffl_woo_sync.woocommerce.tasks.rebucket_and_apply_serial_task).
| arg | type | required | default | description |
|---|---|---|---|---|
serial |
string | yes | — | In-stock firearm Serial No name. |
target_item |
string | yes | — | Destination firearm Item code. |
Returns: {ok, serial, from, to, fastbound_item_id}.
apps/ffl_integrations/ffl_integrations/fastbound/importer.py:534
start_import¶
POST /api/method/ffl_integrations.fastbound.importer.start_import
Auth (derived from code): Roles: System Manager
Run import_bound_book in the background (a whole book outlasts a web
request). The result lands in FastBound Settings.last_import_result and is
announced with the fastbound_import_done event.
| arg | type | required | default | description |
|---|---|---|---|---|
page_size |
integer | no | 100 |
FastBound page size per fetch. |
dry_run |
integer | no | 0 |
1 counts and lists what would happen, writing nothing. |
aggregate_by |
string | no | AGGREGATE_AUTO |
"auto" or "model", as in import_bound_book. |
cutover_date |
string | null | no | None |
The day the bound book is counted as of (default today). |
Returns: {queued: True}.
apps/ffl_integrations/ffl_integrations/fastbound/importer.py:229