ffl_core.agreements¶
Source: apps/ffl_core/ffl_core/agreements.py · 10 endpoint(s)
Generated by
make api-docs— do not edit by hand.
agreements_for_sale¶
POST /api/method/ffl_core.agreements.agreements_for_sale
Auth (derived from code): Requires read permission on Customer (Frappe DocType permission check).
Every active agreement and where this customer stands, for the register's Agreements button.
| arg | type | required | default | description |
|---|---|---|---|---|
customer |
string | yes | — | Customer name (document id). |
items |
list | str | no | None |
sale |
string | null | no | None |
The POS Invoice, once saved. |
Returns: {"rows": [{"template", "scope", "requirement", "required": whether this sale needs it, "skippable": whether a manager may let this sale go without it (:func:skip_for_sale), "state", "expires_on", "agreement", "firearms"}]} — every template once, except an Each firearm sold one with One copy per gun, once per gun. An Each firearm sold row lists the guns one copy is signed for in "firearms": [{"serial_no", "item_code", "item_name", "rate", "state"}] (the guns the sale needs it for, else every gun in the cart; empty when the cart has none); its "state" is signed once every one of them is, pending when the unsigned ones all have a copy out, else missing.
apps/ffl_core/ffl_core/agreements.py:443
get_customer_agreements¶
POST /api/method/ffl_core.agreements.get_customer_agreements
Auth (derived from code): Requires read permission on Customer (Frappe DocType permission check).
The Agreements section of the Customer form.
| arg | type | required | default | description |
|---|---|---|---|---|
customer |
string | yes | — | Customer name (document id). |
Returns: {"rows": [{"name", "template", "serial_no": every gun it covers, comma-separated, "status", "signed_on", "signed_via", "expires_on", "signed_pdf"}] newest first, "can_manage": whether the caller may void or record paper copies}.
apps/ffl_core/ffl_core/agreements.py:986
load_for_signing¶
POST /api/method/ffl_core.agreements.load_for_signing
Auth (derived from code): Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).
What the signing page shows for a one-time link (Guest).
Only the customer's name, the agreement's title and text, and the store's name — nothing else about the customer. Every invalid, used, void or expired link gets the same error. 30 calls an hour per link and 600 per IP address. A copy sent before its template's text changed is shown (and from then on carries) the current text.
| arg | type | required | default | description |
|---|---|---|---|---|
token |
string | yes | — | The token from the link's #t= fragment. |
Returns: {"customer_name", "title", "body_html", "store_name", "minors_need_guardian", "minor_by_dob": true / false from the customer's date of birth, or null when the store keeps none (the page then asks)}.
apps/ffl_core/ffl_core/agreements.py:1081
record_paper_agreement¶
POST /api/method/ffl_core.agreements.record_paper_agreement
Auth (derived from code): Roles: Sales Manager / System Manager
Manager records a copy the customer signed on paper.
The scan must already be attached to this Customer Agreement; it is made private and becomes the signed copy. The copy turns Signed via Paper, its expiry counts from the date on the paper, and who recorded it, when, and the file go on the timeline. A missing signature can never be waived: without a signed scan there is nothing to record.
| arg | type | required | default | description |
|---|---|---|---|---|
name |
string | yes | — | The Pending Customer Agreement. |
file_url |
string | yes | — | The attached scan (PDF or image). |
signer_name |
string | yes | — | Name as signed on the paper. |
paper_signed_on |
string | yes | — | Date written on the paper (YYYY-MM-DD), not in the future. |
participant_is_minor |
integer | no | 0 |
1 when the participant is under 18 (then a Parent or Guardian signed). |
signer_relationship |
string | no | 'Self' |
Self, Parent or Guardian. |
Returns: {"name", "status", "expires_on", "signed_pdf"}.
apps/ffl_core/ffl_core/agreements.py:923
regenerate_signed_pdf¶
POST /api/method/ffl_core.agreements.regenerate_signed_pdf
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Build a signed copy's PDF again (when the background job failed).
| arg | type | required | default | description |
|---|---|---|---|---|
name |
string | yes | — | A Customer Agreement signed on a tablet or by link. |
Returns: {"signed_pdf": file URL}.
apps/ffl_core/ffl_core/agreements.py:1011
request_agreement¶
POST /api/method/ffl_core.agreements.request_agreement
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Send a customer an agreement to sign.
Creates the customer's Pending copy of the template, or re-issues the one
already pending (its old link stops working and its text is rendered again).
While that copy still has a working link — the customer may be signing on the
tablet right now — nothing changes unless replace is 1: the answer is
{"name", "link_open": True, "token_expires"} so the counter can ask first.
| arg | type | required | default | description |
|---|---|---|---|---|
customer |
string | yes | — | Customer name (document id). |
template |
string | yes | — | Agreement Template name; must be active. |
deliver |
string | no | 'qr' |
tablet — send the link to a paired signing tablet (terminal; ffl_core.signing_terminal), which opens it by itself once the request commits (a caller that never commits sends nothing); qr — return the signing link and a QR code for the counter; email — email the link to the customer (refused when the customer has no email address); none — only create the Pending copy (a manager then records a paper copy on it). |
replace |
integer | no | 0 |
1 to re-issue even though the pending copy's link still works. |
terminal |
string | null | no | None |
Signing Terminal name, for tablet; must be active and paired. |
serial_no |
string | null | no | None |
The gun, for an Each firearm sold template (it or firearms is required there). |
price |
number | null | no | None |
The gun's price in this sale, for the text's {{ price }}. |
reference_doctype |
string | null | no | None |
For a Per document template (required there): the record's DocType. |
reference_name |
string | null | no | None |
That record's name; the caller must be able to read it, and the record's agreement_context() fills the text's placeholders. |
firearms |
list | str | no | None |
Returns: {"name": the Customer Agreement, "deliver", "token_expires"} plus, for qr, "sign_url" and "qr_svg" (an SVG data URI); for email, "email". The link itself is never stored.
apps/ffl_core/ffl_core/agreements.py:733
skip_approvers¶
POST /api/method/ffl_core.agreements.skip_approvers
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
Who can approve :func:skip_for_sale for this user.
Returns: {"self": whether a manager is signed in (they approve their own), "approvers": the managers to pick from otherwise: [{"user", "full_name", "has_pin", "pin_off"}]}.
apps/ffl_core/ffl_core/agreements.py:599
skip_for_sale¶
POST /api/method/ffl_core.agreements.skip_for_sale
Auth (derived from code): Roles: Sales User / Sales Manager / Stock Manager / System Manager
A manager lets the next sale to customer from this screen go without the agreements its cart needs.
Only what the cart's Items ask for (a Required by item template, the used-gun one say) can be
skipped — never one every sale needs or one an extension asks for. The approval covers the
agreements unsigned for this cart now: a sale that turns out to need anything else is refused
as usual and does not use it up. A Sales / System Manager signed in approves their own; anyone
else names a manager, who types their counter PIN (or password) — the price approval's list
and checks, lockouts included. Good for :data:SKIP_MINUTES minutes, once, for the user who
asked and this customer: the sale gate (:func:refuse_missing_required) takes it, and on
submit what was unsigned, who approved and why go on the sale's timeline.
| arg | type | required | default | description |
|---|---|---|---|---|
customer |
string | yes | — | Customer name (document id). |
items |
list | str | no | None |
sale |
string | null | no | None |
The POS Invoice, once saved. |
approver |
string | null | no | None |
The manager's user id (from :func:skip_approvers); ignored for a manager signed in. |
pin |
string | null | no | None |
The approver's counter PIN. |
password |
string | null | no | None |
Or their password. |
reason |
string | null | no | None |
Why (optional). |
Returns: {"approver", "approver_name", "expires_in": seconds, "skipped": [{"template", "serial_no"}]}.
apps/ffl_core/ffl_core/agreements.py:550
submit_signature¶
POST /api/method/ffl_core.agreements.submit_signature
Auth (derived from code): Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).
Sign an agreement through a one-time link (Guest).
Checked before anything is written: the "I agree" tick, the typed name, the
token (same error for every invalid one), the signature (a PNG of at most
500 KB and 2000 px with ink on it) and the age rule. A link opened as a QR
code at the counter, or on a paired signing tablet (its device key sent as
terminal_secret; the copy records which tablet), is recorded as signed on
a Tablet, an emailed one as Remote. The link is used up; the signed PDF is built and emailed afterwards.
When the template's text changed after the page was opened, nothing is signed
and the signer is asked to reload and read the new text. 10 calls an hour per
link and 300 per IP address.
| arg | type | required | default | description |
|---|---|---|---|---|
token |
string | yes | — | The token from the link's #t= fragment. |
signature |
string | yes | — | The drawn signature as a PNG data URL. |
agreed |
integer | yes | — | 1 — the signer ticked "I agree". |
signer_name |
string | yes | — | Name typed by the signer. |
participant_is_minor |
integer | no | 0 |
1 when the signer declares the participant is under 18 (ignored when the store keeps the customer's date of birth). |
signer_relationship |
string | no | 'Self' |
Self, or Parent / Guardian when signing for a minor. |
terminal_secret |
string | null | no | None |
The signing tablet's device key, when signed on one. |
Returns: {"signed": true, "store_name"}.
apps/ffl_core/ffl_core/agreements.py:1164
void_agreement¶
POST /api/method/ffl_core.agreements.void_agreement
Auth (derived from code): Roles: Sales Manager / System Manager
Manager voids a copy (sent by mistake, signed by the wrong person).
A Pending copy's link stops working. The copy is kept, marked Void, and the reason goes on its timeline.
| arg | type | required | default | description |
|---|---|---|---|---|
name |
string | yes | — | Customer Agreement name. |
reason |
string | yes | — | Why (required). |
Returns: {"name", "status": "Void"}.
apps/ffl_core/ffl_core/agreements.py:895