Skip to content

ffl_integrations.fastbound.reconcile

Source: apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py · 8 endpoint(s)

Generated by make api-docs — do not edit by hand.

apply_serial_fb_resolution

POST /api/method/ffl_integrations.fastbound.reconcile.apply_serial_fb_resolution

Auth (derived from code): Requires write permission on Serial No (Frappe DocType permission check).

Apply the operator's per-field POS-vs-FastBound resolution choices.

Re-computes the diff first: a field no longer differing is skipped (already_resolved); a field whose FB value changed since shown is skipped (changed); the rest apply against fresh FB values. FB-wins write the Serial No; any POS-win triggers exactly one push_serial_to_fastbound.

arg type required default description
serial string yes — Serial No name (needs Serial No write permission).
resolutions — yes — {field: {"choice": "pos"|"fb", "fb_value": }} — dict or JSON string.

Returns: {ok, applied: {fb: [fields], pos: [fields]}, skipped: [{field, reason}], fastbound_updated} — ok False with a reason when the fresh diff isn't in "ok" state.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:190

clear_not_in_bound_book

POST /api/method/ffl_integrations.fastbound.reconcile.clear_not_in_bound_book

Auth (derived from code): Roles: Stock Manager / System Manager

Undo :func:mark_not_in_bound_book — the record turned out to belong in the

bound book after all. Its sync error is emptied, so the daily retry pushes it again and the Dashboard lists it until it lands; a comment records who cleared it.

arg type required default description
doctype string yes — "FFL Acquisition" or "FFL Disposition".
name string yes — A record marked off the bound book.

Returns: {ok: True, doctype, name}.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:414

compute_serial_fb_diff

POST /api/method/ffl_integrations.fastbound.reconcile.compute_serial_fb_diff

Auth (derived from code): Requires read permission on Serial No (Frappe DocType permission check).

Diff a Serial No's firearm identity against its FastBound item (read-only).

arg type required default description
serial string yes — Serial No name (needs Serial No read permission).

Returns: {status: "ok" | "not_in_fastbound" | "not_configured" | "fb_missing" | "fb_disposed", serial, [fb_item_number], [in_sync], [diffs: [{field, pos_value, fb_value}]], [serial_diff: {pos_value, fb_value} or None]}. serial_diff compares the gun's ledger serial with FastBound's (case and spacing aside); it is outside diffs because a serial is changed with Correct Serial, not by picking a side here.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:108

mark_not_in_bound_book

POST /api/method/ffl_integrations.fastbound.reconcile.mark_not_in_bound_book

Auth (derived from code): Roles: Stock Manager / System Manager

Record that a person checked this submitted record and it does not belong in the

bound book — e.g. an antique (pre-1899 receiver) booked by mistake, which FastBound refuses because it never acquired the gun. The daily retry, the stuck digest and the Dashboard's "Not in the bound book yet" list leave it alone from then on. The record itself is not cancelled (its stock leg is right); the reason, who marked it and the previous sync error are kept as a comment.

arg type required default description
doctype string yes — "FFL Acquisition" or "FFL Disposition".
name string yes — The submitted record FastBound does not have.
reason string yes — Why it is not a bound-book record (required).

Returns: {ok: True, doctype, name}.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:355

match_serial_to_fastbound

POST /api/method/ffl_integrations.fastbound.reconcile.match_serial_to_fastbound

Auth (derived from code): Requires write permission on Serial No (Frappe DocType permission check).

Find and stamp the FastBound item id for an unlinked serial.

For a gun with no fastbound_item_id, finds its FastBound item by serial and stamps the id so it can be reconciled. Uses find_item_by_serial (raises on >1 in-stock match — surfaced to the operator).

arg type required default description
serial string yes — Serial No name (needs Serial No write permission).

Returns: {ok: True, item_id} | {ok: True, already: True} | {ok: False, reason: "not_found" | "not_configured"}.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:273

reconcile_record_to_fastbound

POST /api/method/ffl_integrations.fastbound.reconcile.reconcile_record_to_fastbound

Auth (derived from code): Roles: Stock Manager / System Manager

Link an already-booked POS record to an EXISTING FastBound record.

For the divergence class where the bound book already carries the event (entered directly in FastBound, or a push that landed but lost its id) and the POS record is stuck with a sync error: re-pushing would double-book, so the fix is to adopt the FastBound record's id. fastbound_id is locked after submit on both doctypes — this endpoint is the sanctioned entrance (the 2026-08-21 JV-return incident had to do all of this through a bench console).

Everything is verified against FastBound LIVE before anything is written (fail-closed): the ref must resolve to a real item whose serial matches the record's, and a Disposition additionally requires the item to actually be disposed. An acquisition reconcile also repoints Serial No.fastbound_item_id the way a successful push would.

arg type required default description
doctype string yes — "FFL Acquisition" or "FFL Disposition".
name string yes — The submitted, not-yet-linked record to link.
fastbound_ref string yes — FastBound item GUID, or the bound-book item number shown in FastBound's UI (digits, e.g. "01171").

Returns: {ok: True, fastbound_id, fb_item_id, fb_item_number, serial_repointed}.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:443

retry_disposition_push

POST /api/method/ffl_integrations.fastbound.reconcile.retry_disposition_push

Auth (derived from code): Roles: Stock Manager / System Manager

Re-run the FastBound push for a submitted FFL Disposition that failed.

push_disposition_to_fastbound is a @frappe.task and nothing else — there was no way to re-run one. A push that failed sat in fastbound_sync_error until the next daily reconcile_failed_pushes, which is up to 24 hours with a firearm out of the building and no bound-book entry for it. DISP-2026-02000 spent a day in exactly that state while the obstacle that caused the 400 had already been cleared by hand.

A thin wrapper on purpose: it re-checks who may press it and what may be pressed, then calls the task unchanged. Run INLINE rather than enqueued so the operator sees the outcome — the task is already idempotent (it no-ops on an already-linked record) and carries its own retry/back-off.

The PUSHABLE_DISPOSITION_TYPES check is not decoration. A Retail Sale is a 4473 disposition that FastBound's own wizard owns; pushing one from here would book a to-individual transfer as a plain bound-book entry — a compliance defect, not a sync error. The task would refuse it silently, so this refuses it loudly instead of pretending to have done something. So does FastBound being switched off, for the same reason: the task returns silently on a disabled integration, which behind a button reads as "it failed again, reason unknown".

The task's retry ladder is turned OFF here (_retries=0): an operator is waiting, and the default four attempts with back-off can hold the desk for ~80 seconds before showing anything.

arg type required default description
name string yes — The submitted FFL Disposition to push.

Returns: {ok, name, fastbound_id, fastbound_sync_error} — ok is True only when the push landed an id; a still-failing push returns ok False with the error FastBound gave, so the button can show it.

Permissions: Inventory roles (same gate as :func:reconcile_record_to_fastbound).

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:543

scan_in_stock_fb_diffs

POST /api/method/ffl_integrations.fastbound.reconcile.scan_in_stock_fb_diffs

Auth (derived from code): Requires read permission on Serial No (Frappe DocType permission check).

Kick off a background POS-vs-FastBound diff scan of in-stock firearms.

Scans every in-stock firearm with a fastbound_item_id. The result (which guns differ) is pushed via realtime (event 'fb_diff_scan_done') + a Notification Log when the job finishes.

Returns: {"ok": True, "started": True} — the scan itself is asynchronous.

apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:309