Checkout is how a buyer's won lots turn into a settled invoice and a cleared loadout. Once the ring is closed, the office works the Checkout screen (/sales/[id]/checkout) one buyer at a time: build the invoice, take the money, and only then release the animals. Each buyer's Invoice rolls their won lots into subtotal, adds buyerFeesAmount and taxAmount to give totalDue, and tracks amountPaid against balanceDue as money comes in.
Loadout authorization checks two things independently: the invoice must be PAID and the buyer must not be on holdLoadout. Clearing one does not clear the other.
How it works
Generate the invoice
From the sale's checkout screen, generate invoices from the recorded transactions. Tally reads each buyer's won lots and builds one
Invoiceper buyer, computingsubtotal+buyerFeesAmount+taxAmount=totalDue. Fresh invoices start inDRAFT.Issue the invoice
When the numbers are right, issue it — the invoice moves
DRAFT → ISSUED. An issued invoice is the one you hand the buyer to pay against; it's no longer a working draft.Record payments
As the buyer pays, record each
InvoicePaymentwith itsamountandmethod(CASH,CHECK,ACH,WIRE,CARD,APPLIED_CREDIT, orHOLD_AT_OFFICE) plus an optionalreferenceNumber. A partial payment moves the invoice toPARTIAL;amountPaidclimbs andbalanceDuefalls.Reach PAID
When
balanceDuehits zero the invoice flips toPAIDand stampspaidInFullAt. PAID is the gate everything downstream waits on — nothing leaves the yard until the invoice reads paid in full.Clear the buyer for loadout
Before releasing stock, confirm the buyer has no
holdLoadoutflag set. A hold is a hard stop the office must lift (with a reason) regardless of payment — an unpaid balance and an active hold are two separate blocks.Authorize the loadout
Authorizing is a two-step move: first create a
PENDINGLoadoutTicketfor the buyer, then authorize it. Authorization only succeeds when the invoice isPAID; the ticket movesPENDING → AUTHORIZED, and that authorization is what lets the animals physically leave against the gate crew's ticket.
