Workflow Playbook

Sales Workflow and Payments

Detailed flow for sales, payment collection, stock deduction, and customer ledger effects.

Audience: Sales operators, cashiers, and receivables users.

Collections and Responsibilities

Sales

sales

Invoice and fulfillment document that posts stock-out and customer debt.

Sale Payments

salePayments

Collection records that update amountPaid/paymentStatus on sales.

Customer Ledger

customerBalance

Receivable ledger for invoice, payment, and reversal events.

Workflow Timeline

  1. Step 1

    Step 1: Create sale lines

    Select customer, choose product variant, set quantity and selling price.

  2. Step 2

    Step 2: Save sale first

    Save generates saleNumber and creates persistent sale record required for payment linkage.

  3. Step 3

    Step 3: Stock and invoice effects

    Sale save deducts variant stock and posts customer invoice ledger events.

  4. Step 4

    Step 4: Add payment entries

    Create salePayments with amount, method, and date to update amountPaid and paymentStatus.

  5. Step 5

    Step 5: Keep deletions controlled

    Deleting payment recalculates sale status and posts payment_reversal to customer ledger.

Field Guide (Required vs Optional)

FieldRequirementBehavior

Sale Customer

sales.customer

RequiredMandatory customer on sale header.

Sale Item Quantity

sales.saleItems[].quantity

RequiredRequired and validated against available stock rules.

Sale Selling Price

sales.saleItems[].price

RequiredRequired selling price with validation checks.

Sale Number

sales.saleNumber

Auto / SystemAuto-generated after first save.

Sale Totals

sales.subtotal, sales.taxAmount, sales.total

Auto / SystemServer-side tax and total recalculation is source of truth.

Sale Reference

salePayments.sale

RequiredRequired sale relationship.

Sale Payment Core Fields

salePayments.amount, method, date

RequiredMandatory fields for valid payment posting.

Payment Number

salePayments.paymentNumber

Auto / SystemGenerated automatically as PAY-XXXX.

Delivery Fields

delivery fields (status/date/address/notes)

OptionalOperational delivery tracking, independent from stock deduction timing.

Decision Scenarios

If this happens

Payment is attempted before saving sale

Operationally blocked because no persisted sale context exists yet.

Timing: User workflow order: save sale first, then use Payments tab.

If this happens

Sale line quantities are edited

Stock adjusts by delta between previous and current lines, clamped at zero minimum.

Timing: afterChange on sales update.

If this happens

Payment is created or deleted

Sale amountPaid/paymentStatus and customer ledger are recalculated and synchronized.

Timing: afterChange / afterDelete in salePayments hooks.

Automatic Side Effects

  • Sale tax and totals are recalculated server-side before save.
  • Sale create/update posts invoice and invoice_update events to customer ledger.
  • Payment create/delete posts payment and payment_reversal effects automatically.

Operational Controls

  • Use the payment ledger as the source for collected cash reconciliation.
  • Control payment deletions with approval policy in production.
  • Review historical sale edits because they affect stock and receivables.