Sample output from the Process Mining: Reconstruct Transaction Flows from the Event Log prompt in the Sonar AI Prompt Library, run against a NetSuite test account. Every name and number here is test data. Back to the post · The library
Process Intelligence · Event-Log Reconstruction

Transaction Flow Reconstruction & Conformance Analysis

How orders, invoices, and payments actually move through this NetSuite account — reconstructed from 22,000+ document-link events and the record-level audit trail — measured against the standard order-to-cash and procure-to-pay designs.

AccountTD3016323 (Production, OneWorld)
Report dateAugust 22, 2026
Evidence windowAll history through Aug 22, 2026
ClassificationInternal — Management
Contents

Section 1

Executive summary

This analysis reconstructed the account's end-to-end transaction flows directly from the document-link graph (nexttransactionlinelink, 22,762 line-level link events across 40 distinct transition types) and the record-level audit trail (systemnote), rather than from process documentation. Four conclusions stand out.

95.7%
Orders conform to ship-before-invoice sequence
$472.9K
Receivables more than 90 days past due — 49% of open AR
20
Orders invoiced before goods shipped (sequence inversion)
$4,837
Shipped but never invoiced across 11 orders

First, execution discipline in operations is high. 88.4% of fulfilled orders ship and invoice on the same day; the purchase-to-receipt cycle runs at a median of 0 days with a maximum of 3. The transactional machinery is fast and consistent.

Second, the constraint is not operations — it is receivables. The open invoice queue totals $964,127 (32.7% of all-time invoiced revenue) at an average age of 128 days. $472.9K is more than 90 days past due, including single invoices outstanding 460 and 327 days. By contrast, vendor bills are paid at a median of 3 days — the account systematically extends credit it does not collect while surrendering payables float it is entitled to.

Third, a structured anomaly ran May–July 2026. Eighteen orders followed a uniform inverted pattern — invoiced exactly ~15 days after order, shipped ~46 days after order — inverting the fulfill-then-bill sequence. The same window contains the account's only fulfillment backlog (average ship lag rose from a 0-day baseline to 6–9 days) and virtually all post-creation edit churn. The pattern's uniformity indicates a deliberate arrangement (bill-and-hold-like) or scripted activity, not organic delay; it warrants a policy determination because it carries revenue-recognition implications.

Fourth, the rework loops are small but currently unmanaged. Of four return authorizations opened since July, only one has completed the receive-and-credit cycle; one has held received goods without a credit memo for 37 days. The quotation stage is bypassed for ~99% of orders, and of the 10 quotes that do exist, half expired unactioned.

Key judgment The process map most teams would draw for this account — quote → order → fulfill → invoice → collect — is not the process that runs. The real process is a compressed same-day fulfill-and-bill engine feeding a collections queue that has no effective owner. Fixing the second half is worth roughly 100× more than tuning the first.

Section 2

Method & evidence base

Classic process mining requires an event log: case ID, activity, timestamp. NetSuite does not expose one directly, so three sources were combined to synthesize it:

SourceRole in reconstructionVolume
nexttransactionlinelinkThe document-flow edge list: every line-level link between a predecessor and successor transaction, typed (OrdBill, ShipRcpt, Payment, SaleRet…) and dated on both ends. This is the account's de facto event log.22,762 links · 40 transition types
transactionCase attributes: type, status (single-letter codes), business dates, due dates, open amounts, entities.~7,900 documents
systemnoteRecord-level audit trail: post-creation field edits, actor, and originating context (UI form / Suitelet / RESTlet) — the signal for edit-churn rework invisible in document links.1,001 events on transactions

Cases were built per order: each Sales Order (743 with downstream links) and Purchase Order (724) was traced through its first shipment/receipt, first invoice/bill, and payment, with lag computed at each hop. Conformance was tested by classifying every case into its observed variant (the actual sequence of steps) and comparing against the reference model below. All 14 queries used are reproduced verbatim in the Appendix.

Reference model (the "standard process") Order-to-cash: Estimate → Sales Order → Item Fulfillment → Invoice → Customer Payment, with returns via RMA → Item Receipt → Credit Memo.
Procure-to-pay: Purchase Order → Item Receipt → Vendor Bill (3-way match) → Bill Payment, with returns via Vendor RMA → Fulfillment → Vendor Credit.

Section 3

The process as observed

The transition-frequency map below is drawn purely from link events — it shows where documents actually go, weighted by how many document pairs traverse each edge. Solid edges carry the volume; dashed nodes are stages the standard model expects but the data shows are nearly vacant.

Order-to-cash — observed main flow (distinct document pairs)
Estimate
1 pair
(0.1%)
Sales Order · 788
735 pairs
Item Fulfillment
732 pairs
Invoice · 764
736 pairs
Payment
RMA (returns)
4 RMAs · 2 received
Item Receipt
1 credited
Credit Memo
Procure-to-pay — observed main flow
Purchase Order · 740
722 pairs
Item Receipt
705 pairs
Vendor Bill · 1,017
1,005 pairs
Bill Payment

What the map reveals


Section 4

Conformance: designed vs. actual

Every linked sales order was classified into its observed variant. The standard sequence (fulfill, then invoice) holds for 95.7% of cases — but the shape of conformance is a same-day collapse, and the exceptions are not random.

Observed process variants — 743 linked sales orders
Share of cases per variant. Emerald marks the fully conformant standard path.
Shipped + invoiced same day
657 · 88.4%
Shipped, invoiced later
54 · 7.3%
Invoiced BEFORE shipped
20 · 2.7%
Shipped, never invoiced
11 · 1.5%
No shipment recorded
1 · 0.1%

4.1 The inverted-sequence cluster

The 20 invoice-before-shipment cases are dominated by an 18-order cluster (SO4270–SO4287, May–July 2026) with a strikingly uniform signature: invoice raised ~15 days after order date, goods shipped ~46 days after order date — a 29–31 day window in which revenue was billed against unshipped inventory. The affected customers repeat (Design Excellence Ltd. ×4, Meetz Industries, JBL Inc., Godric Motors ×2, Hugo Limited, Marshall Industries, Blockster Inc., Jones Manufacturing). The uniform offsets rule out organic delay; this is either a deliberate billing arrangement (bill-and-hold-like terms) or scripted/batch activity.

OrderOrderedInvoicedShippedBill precedes ship byCustomer
SO42702026-05-032026-05-182026-06-1831 dDesign Excellence Ltd.
SO42712026-05-032026-05-182026-06-1831 dGodric Motors
SO42742026-05-082026-05-232026-06-2331 dMeetz Industries
SO42812026-07-022026-07-172026-08-1731 dMarshall Industries
SO42872026-07-132026-07-312026-08-3131 dDesign Excellence Ltd.
…13 further cluster orders with identical ~+15 d / ~+46 d offsets (full list reproducible via Q7), plus outlier SO3910 — invoiced on order date, shipped 365 days later.
Why this matters Billing ahead of fulfillment recognizes revenue against undelivered goods. If these are genuine bill-and-hold arrangements, they require documented customer acceptance criteria; if they are operational shortcuts, invoicing should be blocked until fulfillment. Either way the pattern needs an explicit policy owner — today it is invisible in every standard report.

4.2 Shipped but never invoiced — direct revenue leakage

Eleven orders show a completed shipment with no downstream invoice link: $4,836.79 of delivered goods with no bill raised. Individually small, but this is precisely the defect class that recurs silently. Largest: SO3174 (Shirley Stephens, $2,270.64, shipped 2026-08-08); the rest span June–September 2026 (Q8 lists all 11).

4.3 Procure-to-pay conformance

P2P is the mirror image: near-perfect. 722 of 724 traced POs received before billing (only 2 billed before receipt), median receipt lag 0 days, maximum 3 days, bill raised ~1 day post-receipt. The 3-way-match sequence is effectively self-enforcing here.


Section 5

Bottlenecks & cycle times

Stage transitionCasesMedianAverageMaxReading
Sales Order → Shipment7420 d1.6 d365 dExcellent baseline; average distorted by the May–Jul cluster
Sales Order → Invoice7320 d0.6 dBilling keeps pace with fulfillment
Invoice → Payment (paid pop.)7360 d1.7 d272 dSurvivors pay fast — the problem population is the unpaid queue (§7)
Purchase Order → Receipt7240 d0.0 d3 dEffectively instantaneous
Receipt → Vendor Bill7051 d1.0 dTight 3-way match
Vendor Bill → Payment1,0043 d3.5 d991 of 1,004 paid within 5 days — faster than terms require (§7)

5.1 The May–July 2026 fulfillment backlog — visible only in the event log

Monthly average ship-lag was zero for eight consecutive months, then rose sharply in May 2026 and self-cleared by August. The backlog is entirely attributable to the 18-order inverted cluster plus a handful of adjacent delays — 18 orders exceeded 30 days in the window. No aggregate KPI on the standard dashboards would surface this: monthly shipment counts stayed normal (33–44/month) while individual orders quietly aged.

Average SO → shipment lag by order month (days)
Bars: mean lag. The disruption window is rendered in slate; the stable baseline in silver-gray. Aug-26 mean is slightly negative (backdating artifact — see §10).
0 10 d Sep-25OctNov DecJan-26Feb MarApr May Jun Jul Aug 7.06.08.9 Baseline: 0.0 avg for 8 straight months

5.2 Current open queues (as of Aug 22, 2026)

QueueDocsAvg ageMax ageValueObservation
Open invoices (AR)39128 d536 d$964,127The dominant bottleneck — see §7
SOs pending fulfillment (B)4018 d99 d$73,709Watch: several already exceed the 30-day threshold
SOs pending approval (A)1312 d21 d$55,892Approval latency delays $56K of pipeline
Open vendor bills (A)926 d74 d$180,934Includes Davidson Leasing $120,000 (19 d) and two 43–74 d intercompany allocations
Vendor bills pending approval (D)427 d82 d$3,114Oldest: Bedline $1,500 stalled 82 days in approval
POs pending billing (F)1930 d103 d$29,707Receipt done, bill never arrived — accrual exposure
Open RMAs218 d20 d$206Plus one received-not-credited (§6.1)

Section 6

Rework loops

6.1 The returns loop stalls at the credit step

Return volume is negligible (4 RMAs against 788 orders — 0.5%), and returns only began in July 2026. But the loop that exists does not close: the designed sequence RMA → receive goods → issue credit has completed exactly once.

RMAOpenedCustomerGoods receivedCredit issuedState
RMA232026-07-05Design Excellence Ltd.YesYesComplete — the only closed loop
RMA242026-07-16Design Excellence Ltd.YesNoReceived 37 days ago, customer still awaiting credit
RMA252026-08-02Design Excellence Ltd.NoNoAwaiting goods, 20 d
RMA262026-08-06Design Excellence Ltd.NoNoAwaiting goods, 16 d

All four RMAs belong to one customer — Design Excellence Ltd. — who is also the most frequent name in the inverted-billing cluster (§4.1). This account concentrates a disproportionate share of every anomaly in the dataset and merits a dedicated account review.

6.2 Edit churn: rework concentrated on exactly the anomalous orders

Post-creation edits are the invisible rework of ERP processes. The audit trail shows a starkly bimodal distribution: 774 of 788 sales orders (98.2%) were never edited after creation, while 14 orders absorbed all the churn — 9 to 39 field-change events each, touching 12–16 distinct fields (amounts, revenue status, addresses, shipped/picked quantities). Those 14 churned orders sit in the same April–August window and the same SO42xx range as the inverted-billing cluster. Actor analysis (Q10) attributes the edits to a single administrator, executed predominantly through Suitelet and RESTlet contexts (SLT 71%, RST 12%) rather than the UI — i.e., tool-driven activity, consistent with the scripted-pattern hypothesis in §4.1.

6.3 The quote stage: a loop that never engages

10 estimates all-time vs. 788 orders. One converted (10%), five expired (50%), four remain open. Quoting appeared in July 2026, presumably as a new practice — at current conversion it adds an administrative step with no measurable funnel value. Either commit to it (route the wholesale channel through quotes, track conversion) or drop it.


Section 7

The working-capital asymmetry

Putting both cash cycles side by side exposes the account's most expensive habit. Vendor bills are settled at a median of 3 days — 991 of 1,004 within 5 days — surrendering essentially all payables float (on Net-30 terms, ~26 days of free financing per bill). Customers who pay do so quickly, but the unpaid queue is aging without intervention: 39 invoices, $964K, of which 49% is beyond 90 days past due.

Open receivables by aging bucket — $964,127 total
Days past due. Emerald marks the only healthy bucket.
Current (not yet due)
$129,007
1–30 days
$6,191
31–90 days
$320,136
91–180 days
$165,159
180+ days
$307,754

Ten invoices are 87% of the problem

InvoiceCustomerDue dateDays past dueOpen amount
INV790Global Information2025-12-03262$110,579.17
INV782Red Rivers Consulting2026-03-20155$102,905.76
INV774Magna Tech Limited2026-07-2132$97,942.27
INV783Falcon Systems2026-06-0182$86,007.39
INV791Mercury Co.2025-05-19460$80,079.02
INV789Gotter inc.2025-12-09256$68,119.00
INV759Blockster Inc.2026-06-0380$53,424.00
INV788Haskell Associates2025-09-29327$43,940.75
INV784John G. Roche Opticians2026-04-15129$31,810.19
INV780Informics International2026-03-23152$29,239.18
Top 10 concentration$704,047 · 73% of open AR

The paid population proves customers in this book can pay fast (median 0 days; only 44 of 736 paid invoices were ever late). The aged queue is therefore not a customer-behavior problem across the portfolio — it is a small set of large accounts with no active collections process. Ten phone calls address $704K.


Section 8

Findings register

F1
High
$472.9K of receivables beyond 90 days past due with no collections cadence

49% of open AR sits past the 90-day mark, including invoices at 460, 327, 262 and 256 days. Open AR equals 32.7% of all-time invoiced revenue. The paid population's near-instant behavior demonstrates the gap is process absence, not customer inability.

Exposure: $472,913 aged AR; collectability deteriorates sharply past 180 days. Evidence: Q11, Q12.
F2
High
Systematic invoice-before-shipment pattern, May–July 2026

18 orders billed ~15 days after order and shipped ~46 days after order — a uniform 29–31-day billed-but-unshipped window, repeated across 9 customers. Revenue-recognition treatment depends on whether documented bill-and-hold criteria exist; none are referenced on the transactions.

Exposure: ~$18.9K across the cluster; the control gap, not the amount, is the issue. Evidence: Q6, Q7.
F3
Medium
Eleven orders shipped and never invoiced

$4,836.79 of delivered goods with no bill raised, spanning June–September 2026. No standard report flags this population; it was only visible by set-differencing the link graph.

Exposure: direct revenue leakage; recurring defect class. Evidence: Q8.
F4
Medium
Payables float surrendered: bills paid in 3 days against (presumed) 30-day terms

Median bill-to-payment of 3 days across 1,004 payments; 98.7% paid within 5 days. Unless early-payment discounts are being captured (none evident on the bills), this forgoes ~26 days of float on the entire payables book while $964K of receivables goes uncollected.

Exposure: structural cash-conversion drag. Evidence: Q5.
F5
Medium
Fulfillment backlog May–July 2026, invisible to aggregate KPIs

Average ship lag rose from a 0-day 8-month baseline to 6.0–8.9 days; 18 orders exceeded 30 days. Monthly shipment counts stayed normal throughout, so volume dashboards showed nothing. Cleared by August without intervention — meaning it could recur the same silent way.

Exposure: customer-experience risk; 40 SOs currently pending fulfillment (avg 18 d, max 99 d). Evidence: Q4, Q9.
F6
Medium
Approval queues without SLAs: 82-day vendor-bill approval; $56K of orders awaiting approval

Four vendor bills pending approval (oldest 82 days), 13 sales orders pending approval averaging 12 days, and a $120K vendor bill sitting open-unapproved-for-payment 19 days. Nineteen POs are received-but-unbilled up to 103 days (accrual exposure at close).

Exposure: $3.1K stalled in approval, $55.9K sales pipeline delayed, $29.7K unbilled receipts. Evidence: Q9, Q13.
F7
Low
Returns loop stalls at the credit step

Of 4 RMAs, one completed the full receive-and-credit cycle; RMA24's goods were received 37 days ago with no credit memo issued. All four RMAs belong to one customer (Design Excellence Ltd.), who also recurs throughout the F2 cluster.

Exposure: $464 in returns; customer-relationship and inventory-accuracy risk. Evidence: Q3 (SaleRet edges), §6.1 trace.
F8
Low
Quotation stage bypassed by ~99% of order flow

10 estimates vs. 788 orders; 10% conversion; 50% expiry. The stage exists in the reference model and in the account's form set, but not in practice.

Exposure: none direct — a design-vs-reality gap to resolve deliberately. Evidence: Q14.
F9
Info
Edit churn is bimodal and tool-driven

98.2% of sales orders have zero post-creation edits; 14 orders absorb all churn (up to 39 field changes), executed predominantly via Suitelet/RESTlet contexts by a single administrator, coinciding with the F2 cluster window.

Evidence: Q9, Q10.
F10
Info
Document backdating limits timestamp fidelity

Several August–September shipments carry dates earlier than their order dates (negative lags), proving trandate is an editable business date, not an event timestamp. Cycle-time figures herein are therefore best-estimate, floor-biased where backdating occurred (see §10).

Evidence: Q4 (Aug/Sep rows).

Section 9

Recommendations

  1. Stand up a collections cadence this week (F1). Ten invoices are 73% of open AR. Assign an owner, contact the top ten, and instrument the queue: a saved search on CustInvc status A bucketed by days-past-due, reviewed weekly. Target: nothing crosses 60 days without a documented action.
  2. Adopt a payables calendar (F4). Schedule bill payments to terms minus a safety margin (e.g., day 25 on Net 30) unless a discount justifies early payment. This is a settings-and-habit change, not a build.
  3. Make a policy determination on the billed-before-shipped pattern (F2). If bill-and-hold is intended for these wholesale accounts, document acceptance criteria on the orders; if not, enforce sequence with an invoice-time validation (block or warn when invoicing an order with unfulfilled quantity).
  4. Close the leakage set (F3). Invoice or formally close the 11 shipped-uninvoiced orders, then keep a permanent exception search: fulfillments > N days old with no linked invoice. This report's Q8 is the exact query.
  5. Publish SLAs on the three approval queues (F6) — vendor-bill approval, SO approval, receipt-to-bill — with a weekly aging review. The event log shows queues only misbehave when nobody is measured on them.
  6. Close the RMA24 credit and put a 7-day receive-to-credit SLA on returns (F7). Volume is tiny now; the habit is cheap to install before volume grows.
  7. Decide the quote stage's fate (F8) — mandate it for the wholesale channel with conversion tracking, or retire it. The current state (10 quotes, half expiring) is the worst of both.
  8. Institutionalize this analysis. Every query herein is re-runnable. A monthly "flow-conformance" pack — variants, lag trend, exception sets — would have caught F2/F5 in May rather than August. This pairs naturally with the account's existing monthly-management-reporting process definition, or as a small standalone process.

Section 10

Assumptions & limitations


Appendix A

Queries used

All queries are SuiteQL, run read-only against the live account on August 22, 2026. Each is reproducible as-is. Conventions follow the account's house style (uppercase keywords, standard aliases, rounded money).

Q1Transition-frequency map (the process map's edge list)
SELECT
    previoustype,
    linktype,
    nexttype,
    COUNT(DISTINCT previousdoc || '-' || nextdoc) AS doc_pairs,
    COUNT(*)                                      AS line_links
FROM nexttransactionlinelink
GROUP BY previoustype, linktype, nexttype
ORDER BY COUNT(*) DESC
Q2Status distribution across O2C / P2P document types
SELECT type, status, COUNT(*) AS n
FROM transaction
WHERE type IN ('SalesOrd','CustInvc','ItemShip','CustPymt','RtnAuth','CustCred',
               'Estimate','PurchOrd','ItemRcpt','VendBill','VendPymt','CashSale','CashRfnd')
GROUP BY type, status
ORDER BY type, COUNT(*) DESC
Q3O2C stage cycle times (SO → ship / invoice)
SELECT
    COUNT(*)                                                  AS so_count,
    ROUND(AVG(first_ship - so_date), 1)                       AS avg_so_to_ship,
    ROUND(MEDIAN(first_ship - so_date), 1)                    AS med_so_to_ship,
    MAX(first_ship - so_date)                                 AS max_so_to_ship,
    ROUND(AVG(first_inv - so_date), 1)                        AS avg_so_to_inv,
    SUM(CASE WHEN first_inv < first_ship THEN 1 ELSE 0 END)   AS invoiced_before_ship,
    SUM(CASE WHEN first_inv = first_ship THEN 1 ELSE 0 END)   AS invoiced_same_day
FROM (
    SELECT l.previousdoc AS so_id,
           MIN(l.previousdate)                                          AS so_date,
           MIN(CASE WHEN l.nexttype = 'ItemShip' THEN l.nextdate END)   AS first_ship,
           MIN(CASE WHEN l.nexttype = 'CustInvc' THEN l.nextdate END)   AS first_inv
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'SalesOrd'
    GROUP BY l.previousdoc
)
Q4Monthly ship-lag trend (backlog detection)
SELECT
    TO_CHAR(so_date, 'YYYY-MM')                    AS month,
    COUNT(*)                                       AS shipped_orders,
    ROUND(AVG(lag), 1)                             AS avg_lag,
    MAX(lag)                                       AS max_lag,
    SUM(CASE WHEN lag > 30 THEN 1 ELSE 0 END)      AS over_30d
FROM (
    SELECT MIN(l.previousdate) AS so_date,
           MIN(CASE WHEN l.nexttype = 'ItemShip' THEN l.nextdate END)
             - MIN(l.previousdate) AS lag
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'SalesOrd'
    GROUP BY l.previousdoc
)
WHERE lag IS NOT NULL AND so_date >= TO_DATE('2025-09-01', 'YYYY-MM-DD')
GROUP BY TO_CHAR(so_date, 'YYYY-MM')
ORDER BY TO_CHAR(so_date, 'YYYY-MM')
Q5P2P cycle times and payment-timing behavior
-- PO -> receipt / bill
SELECT COUNT(*) AS po_count,
       ROUND(AVG(first_rcpt - po_date), 1)  AS avg_po_to_rcpt,
       MAX(first_rcpt - po_date)            AS max_po_to_rcpt,
       ROUND(AVG(first_bill - po_date), 1)  AS avg_po_to_bill,
       SUM(CASE WHEN first_bill < first_rcpt THEN 1 ELSE 0 END) AS billed_before_receipt
FROM (
    SELECT l.previousdoc AS po_id,
           MIN(l.previousdate)                                        AS po_date,
           MIN(CASE WHEN l.nexttype = 'ItemRcpt' THEN l.nextdate END) AS first_rcpt,
           MIN(CASE WHEN l.nexttype = 'VendBill' THEN l.nextdate END) AS first_bill
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'PurchOrd'
    GROUP BY l.previousdoc
);

-- Bill -> payment (DPO proxy)
SELECT COUNT(*)                                    AS bill_count,
       ROUND(MEDIAN(pay_date - bill_date), 1)      AS med_days_to_pay,
       SUM(CASE WHEN pay_date - bill_date <= 5 THEN 1 ELSE 0 END) AS paid_within_5d
FROM (
    SELECT l.previousdoc AS bill_id,
           MIN(l.previousdate) AS bill_date,
           MIN(l.nextdate)     AS pay_date
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'VendBill' AND l.linktype = 'Payment'
    GROUP BY l.previousdoc
)
Q6Process-variant classification (conformance)
SELECT variant, COUNT(*) AS orders
FROM (
    SELECT l.previousdoc,
           CASE
             WHEN MIN(CASE WHEN l.nexttype='ItemShip' THEN l.nextdate END) IS NULL
               THEN 'No shipment yet'
             WHEN MIN(CASE WHEN l.nexttype='CustInvc' THEN l.nextdate END) IS NULL
               THEN 'Shipped, never invoiced'
             WHEN MIN(CASE WHEN l.nexttype='CustInvc' THEN l.nextdate END)
                < MIN(CASE WHEN l.nexttype='ItemShip' THEN l.nextdate END)
               THEN 'Invoiced BEFORE shipped'
             WHEN MIN(CASE WHEN l.nexttype='CustInvc' THEN l.nextdate END)
                = MIN(CASE WHEN l.nexttype='ItemShip' THEN l.nextdate END)
               THEN 'Shipped + invoiced same day'
             ELSE 'Shipped then invoiced later'
           END AS variant
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'SalesOrd'
    GROUP BY l.previousdoc
)
GROUP BY variant
ORDER BY COUNT(*) DESC
Q7Sequence violations: invoiced before shipped
SELECT so.tranid AS so_num,
       TO_CHAR(so.trandate,  'YYYY-MM-DD') AS so_date,
       TO_CHAR(x.first_inv,  'YYYY-MM-DD') AS invoiced,
       TO_CHAR(x.first_ship, 'YYYY-MM-DD') AS shipped,
       x.first_ship - x.first_inv          AS inv_leads_ship_by
FROM (
    SELECT l.previousdoc AS so_id,
           MIN(CASE WHEN l.nexttype='ItemShip' THEN l.nextdate END) AS first_ship,
           MIN(CASE WHEN l.nexttype='CustInvc' THEN l.nextdate END) AS first_inv
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'SalesOrd'
    GROUP BY l.previousdoc
) x
JOIN transaction so ON so.id = x.so_id
WHERE x.first_inv < x.first_ship
ORDER BY x.first_ship - x.first_inv DESC
Q8Revenue leakage: shipped but never invoiced
SELECT so.tranid,
       TO_CHAR(so.trandate, 'YYYY-MM-DD')   AS so_date,
       so.status,
       c.entityid                           AS customer,
       ROUND(ABS(so.foreigntotal), 2)       AS amt,
       TO_CHAR(x.first_ship, 'YYYY-MM-DD')  AS shipped
FROM (
    SELECT l.previousdoc AS so_id,
           MIN(CASE WHEN l.nexttype='ItemShip' THEN l.nextdate END) AS first_ship,
           MIN(CASE WHEN l.nexttype='CustInvc' THEN l.nextdate END) AS first_inv
    FROM nexttransactionlinelink l
    WHERE l.previoustype = 'SalesOrd'
    GROUP BY l.previousdoc
) x
JOIN transaction so   ON so.id = x.so_id
LEFT JOIN customer c  ON c.id  = so.entity
WHERE x.first_ship IS NOT NULL AND x.first_inv IS NULL
ORDER BY ABS(so.foreigntotal) DESC
Q9Open work queues with age and value
SELECT t.type, t.status, COUNT(*) AS n,
       ROUND(AVG(TRUNC(SYSDATE) - t.trandate), 0) AS avg_age_days,
       MAX(TRUNC(SYSDATE) - t.trandate)           AS max_age_days,
       ROUND(SUM(t.foreigntotal), 2)              AS total_value
FROM transaction t
WHERE (t.type = 'SalesOrd' AND t.status IN ('A','B','E','F'))
   OR (t.type = 'CustInvc' AND t.status = 'A')
   OR (t.type = 'PurchOrd' AND t.status IN ('A','B','F'))
   OR (t.type = 'VendBill' AND t.status IN ('A','D'))
   OR (t.type = 'Estimate' AND t.status = 'A')
   OR (t.type = 'RtnAuth'  AND t.status IN ('A','B'))
GROUP BY t.type, t.status
ORDER BY t.type, t.status
Q10Edit churn from the audit trail (rework signal)
-- Distribution of post-creation edits per sales order
SELECT churn_bucket, COUNT(*) AS orders
FROM (
    SELECT t.id,
           CASE WHEN COUNT(sn.recordid) = 0  THEN '0 edits'
                WHEN COUNT(sn.recordid) <= 3  THEN '1-3'
                WHEN COUNT(sn.recordid) <= 8  THEN '4-8'
                WHEN COUNT(sn.recordid) <= 15 THEN '9-15'
                ELSE '16+' END AS churn_bucket
    FROM transaction t
    LEFT JOIN systemnote sn
           ON sn.recordid = t.id AND sn.recordtypeid = -30 AND sn.type = 2
    WHERE t.type = 'SalesOrd'
    GROUP BY t.id
)
GROUP BY churn_bucket;

-- Actor and originating context (UI form vs Suitelet vs RESTlet)
SELECT e.entityid AS actor, sn.context, COUNT(*) AS edits
FROM systemnote sn
JOIN transaction t   ON t.id = sn.recordid
LEFT JOIN employee e ON e.id = sn.name
WHERE sn.recordtypeid = -30 AND sn.type = 2 AND t.type = 'SalesOrd'
GROUP BY e.entityid, sn.context
ORDER BY COUNT(*) DESC
Q11AR aging buckets on the open-invoice queue
SELECT CASE
         WHEN TRUNC(SYSDATE) - inv.duedate <= 0   THEN 'Current'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 30  THEN '1-30'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 90  THEN '31-90'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 180 THEN '91-180'
         ELSE '180+' END                       AS aging_bucket,
       COUNT(*)                                AS invoices,
       ROUND(SUM(inv.foreignamountunpaid), 2)  AS open_amt
FROM transaction inv
WHERE inv.type = 'CustInvc' AND inv.status = 'A'
GROUP BY CASE
         WHEN TRUNC(SYSDATE) - inv.duedate <= 0   THEN 'Current'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 30  THEN '1-30'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 90  THEN '31-90'
         WHEN TRUNC(SYSDATE) - inv.duedate <= 180 THEN '91-180'
         ELSE '180+' END
Q12Largest open invoices (collections target list)
SELECT inv.tranid,
       TO_CHAR(inv.trandate, 'YYYY-MM-DD') AS inv_date,
       TO_CHAR(inv.duedate,  'YYYY-MM-DD') AS due,
       TRUNC(SYSDATE) - inv.duedate        AS days_overdue,
       c.entityid                          AS customer,
       ROUND(inv.foreignamountunpaid, 2)   AS open_amt
FROM transaction inv
LEFT JOIN customer c ON c.id = inv.entity
WHERE inv.type = 'CustInvc' AND inv.status = 'A'
ORDER BY inv.foreignamountunpaid DESC
FETCH FIRST 12 ROWS ONLY
Q13Stuck vendor-bill queue (open + pending approval)
SELECT vb.tranid,
       TO_CHAR(vb.trandate, 'YYYY-MM-DD') AS bill_date,
       vb.status,
       TRUNC(SYSDATE) - vb.trandate       AS age_days,
       v.entityid                         AS vendor,
       ROUND(ABS(vb.foreigntotal), 2)     AS amt
FROM transaction vb
LEFT JOIN vendor v ON v.id = vb.entity
WHERE vb.type = 'VendBill' AND vb.status IN ('A','D')
ORDER BY vb.status DESC, ABS(vb.foreigntotal) DESC
Q14Quote-to-order conversion and RMA loop tracing
-- Every estimate and whether it ever converted
SELECT est.tranid,
       TO_CHAR(est.trandate, 'YYYY-MM-DD') AS est_date,
       est.status,
       ROUND(est.foreigntotal, 2)          AS total,
       MAX(CASE WHEN l.nexttype = 'SalesOrd' THEN 1 ELSE 0 END) AS converted
FROM transaction est
LEFT JOIN nexttransactionlinelink l
       ON l.previousdoc = est.id AND l.previoustype = 'Estimate'
WHERE est.type = 'Estimate'
GROUP BY est.tranid, est.trandate, est.status, est.foreigntotal
ORDER BY est.trandate;

-- Each RMA traced through receipt and credit
SELECT ra.tranid,
       TO_CHAR(ra.trandate, 'YYYY-MM-DD') AS ra_date,
       ra.status,
       MAX(CASE WHEN l.nexttype = 'ItemRcpt' THEN 1 ELSE 0 END) AS received,
       MAX(CASE WHEN l.nexttype = 'CustCred' THEN 1 ELSE 0 END) AS credited,
       c.entityid AS customer
FROM transaction ra
LEFT JOIN nexttransactionlinelink l
       ON l.previousdoc = ra.id AND l.previoustype = 'RtnAuth'
LEFT JOIN customer c ON c.id = ra.entity
WHERE ra.type = 'RtnAuth'
GROUP BY ra.tranid, ra.trandate, ra.status, c.entityid
ORDER BY ra.trandate
§ END OF REPORT · 11 SECTIONS · 14 QUERIES · TD3016323