Pranav GudiseCode on GitHub

Sales tax return checks

SQL checks that run on every prepared monthly return before it is filed. Each return lands in one tier: blocked (a person must fix or clear it), full review, or sampled review. The checks run in your browser with SQLite.

5 returns blocked

October 2026 returns, ready to file and due November 30

Planted errors caught 6 of 6
5Blocked
1Full review
2Sampled review

Six planted errors stop five returns, one of which was never prepared. A real 47% sales spike goes to full review, not blocked.

Only merchant M4 is clean, so its two returns go to the sampled pool. Every check recomputes the return from the sales and compares it with what was prepared.

October queue

One card per return, built live from the check results. Tax due is the total on the prepared return.

Loading…

Checks by return

Which check fired on which return. One block-level hit is enough to stop a return; review-level hits send it to full review.

Loading…

What each check found

Line comparisons allow $1 for rounding; collected_vs_due uses $25 and swing uses 30% and $2,000. Open a check to see its SQL.

Try your own query

Tables: transactions, return_lines, returns, rates, exemption_certificates, registrations, merchants, jurisdictions. Views: txn_rated (each sale with its rates and treatment), expected_lines (each return line recomputed from the sales), reported_lines.

or Ctrl / ⌘ + Enter

Planted errors

Six errors were planted in the October returns:

  1. A local rate rose on October 1 and one return kept the old rate.
  2. A sale was treated as exempt under a certificate that expired the day before the month started.
  3. Marketplace sales (where the marketplace collects the tax) were taxed again instead of deducted.
  4. A merchant's first sales into a new local district were left off the return.
  5. A merchant had sales in a registered state but no return was prepared.
  6. One day of sales in one local district never reached the return.

Plus one real event that is not an error: a promotion pushed one merchant's taxable sales up 47%. That return should go to review, not be blocked. The tests assert that each error is caught by the right check, that the clean merchant raises nothing, and that the spike lands in review rather than blocked.

Two rules in the operating plan are not in the demo: a customer's first return in a state always gets full review, and 10% of the sampled pool is drawn for a full read each cycle.