docs(sales-summaries): show line-level before and after for each repair

The report asserted that the fixes work; it did not show what changed on the
page. Replaces the worked-examples section with actual summary lines pulled from
the restore, before and after, including debit and credit totals.

NGLK 2026-08-04 is the clearest case. The day already carried a $60.00 card
refund — the guest was given their money back, tip included — while the Tip line
still credited $482.94, because the reversal sits on an order with no tender and
get-tip only reached tips through tenders. Corrected to $422.94, matching the
refund to the cent, and the day closes from -60.00 to 0.00.

NTPT 2026-08-06 shows the other shape: $427.10 of service charge arrived inside
a $4,975.89 card tender, so it landed on the debit side with nothing crediting
it. Credits go 7,350.10 to 7,777.20 against unchanged debits of 7,777.20.

Adds the six largest repairs of each kind with their real Tip and Service
Charges figures, and NGNP 2026-06-25 where both fixes land on one day and pull
in opposite directions — 301.40 credited, 1.80 removed, 299.60 closed — which is
a useful check that the two are independent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 13:10:58 -07:00
parent 41a1eb04a8
commit 5997c42bf5

View File

@@ -229,42 +229,108 @@
</section> </section>
<section> <section>
<h2>Worked examples</h2> <h2>What actually changed on the page</h2>
<div class="measure"> <div class="measure">
<p>Each fix is easiest to check on a single order. In both cases the day's imbalance equals the fix amount exactly, which is what you would expect if the fix books something real that was previously booked nowhere.</p> <p>Both fixes add a single credit line. Nothing else in a summary moves — no sales figure, no
tender, no tax. That is why they can only ever help a day that was already short, and it is
visible in the line items.</p>
</div> </div>
<h3>R1 — a tip reversal with no tender to hang it on</h3> <h3>R1 — NGLK, 2026-08-04</h3>
<div class="scroll"> <div class="scroll">
<table> <table>
<thead><tr><th>Field</th><th>Value</th></tr></thead> <thead><tr><th>Line</th><th class="n">Before</th><th class="n">After</th><th class="n">Change</th></tr></thead>
<tbody> <tbody>
<tr><td>Order</td><td class="mono">square/order/NGLK-SM-OxSX9gpXJV394qqT8mnBGypUwKNZY</td></tr> <tr><td><strong>Tip</strong> (credit)</td><td class="n">482.94</td><td class="n">422.94</td><td class="n bad">60.00</td></tr>
<tr><td><code>:sales-order/tip</code></td><td class="n">60.00</td></tr> <tr><td class="dim">Card Refunds (credit)</td><td class="n dim">60.00</td><td class="n dim">60.00</td><td class="n dim"></td></tr>
<tr><td><code>:sales-order/total</code></td><td class="n">60.00</td></tr> <tr><td class="dim">every other line</td><td class="n dim" colspan="2">unchanged</td><td class="n dim"></td></tr>
<tr><td><code>:sales-order/charges</code></td><td class="n bad">0 — no tender at all</td></tr> <tr><td>Total debits</td><td class="n">10,094.81</td><td class="n">10,094.81</td><td class="n dim"></td></tr>
<tr class="total"><td>NGLK 2026-08-04 imbalance</td><td class="n">60.00 → 0.00</td></tr> <tr><td>Total credits</td><td class="n">10,154.81</td><td class="n">10,094.81</td><td class="n">60.00</td></tr>
<tr class="total"><td>Imbalance</td><td class="n bad">60.00</td><td class="n good">0.00</td><td class="n">balanced</td></tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="measure"> <div class="measure">
<p>A guest's tip was handed back. The reversal is recorded on the order, but <code>get-tip</code> reaches tips by joining through <code>:sales-order/charges</code>, and a return-only order has no charge to join through — so the $60.00 was invisible and the day credited a tip that no longer existed.</p> <p>Read the two credit lines together and the story is complete: the day already carried a
<strong>$60.00 card refund</strong> — the guest was given their money back, tip included — but the
tip was still credited in full at $482.94, because the reversal lives on an order with no tender
and <code>get-tip</code> only reached tips through tenders. The books claimed $60 of tip income
that had been handed back. The corrected figure, $422.94, matches the refund exactly.</p>
</div> </div>
<h3>R2 — a service charge collected but credited nowhere</h3> <h3>R2 — NTPT, 2026-08-06</h3>
<div class="scroll"> <div class="scroll">
<table> <table>
<thead><tr><th>Field</th><th>Value</th></tr></thead> <thead><tr><th>Line</th><th class="n">Before</th><th class="n">After</th><th class="n">Change</th></tr></thead>
<tbody> <tbody>
<tr><td>Order</td><td class="mono">square/order/NTPT-PT-KrMZzcon1cpQEJUyetErkBIpcdEZY</td></tr> <tr><td><strong>Service Charges</strong> (credit)</td><td class="n bad">absent</td><td class="n">427.10</td><td class="n good">+427.10</td></tr>
<tr><td><code>:sales-order/service-charge</code></td><td class="n">427.10</td></tr> <tr><td class="dim">Card Payments (debit)</td><td class="n dim">4,975.89</td><td class="n dim">4,975.89</td><td class="n dim"></td></tr>
<tr><td><code>:sales-order/total</code></td><td class="n">3,198.78</td></tr> <tr><td class="dim">every other line</td><td class="n dim" colspan="2">unchanged</td><td class="n dim"></td></tr>
<tr class="total"><td>NTPT 2026-08-06 imbalance</td><td class="n">+427.10 → 0.00</td></tr> <tr><td>Total debits</td><td class="n">7,777.20</td><td class="n">7,777.20</td><td class="n dim"></td></tr>
<tr><td>Total credits</td><td class="n">7,350.10</td><td class="n">7,777.20</td><td class="n">+427.10</td></tr>
<tr class="total"><td>Imbalance</td><td class="n bad">+427.10</td><td class="n good">0.00</td><td class="n">balanced</td></tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="measure"> <div class="measure">
<p>The $427.10 sits inside the card tender the customer paid, so it lands on the debit side — but nothing credited it, leaving the day short by exactly that amount. R2 is the larger of the two fixes by an order of magnitude: $54,775.79 moved against R1's $3,623.44.</p> <p>The customer paid $427.10 of service charge as part of a $4,975.89 card tender, so the money
arrived on the debit side. No line credited it, so the day showed $427.10 more collected than
earned. Adding the credit closes it exactly, and the single order responsible is
<span class="mono">square/order/NTPT-PT-KrMZzcon1cpQEJUyetErkBIpcdEZY</span>, carrying a
<code>:sales-order/service-charge</code> of 427.10 on a 3,198.78 order.</p>
</div>
<h3>The largest tip repairs</h3>
<div class="scroll">
<table>
<thead><tr><th>Client</th><th>Date</th><th class="n">Tip before</th><th class="n">Tip after</th><th class="n">Imbalance before</th><th class="n">After</th></tr></thead>
<tbody>
<tr><td class="mono">NGFL</td><td>2026-05-19</td><td class="n">238.46</td><td class="n">70.42</td><td class="n bad">168.04</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGMI</td><td>2026-07-09</td><td class="n">230.01</td><td class="n">80.01</td><td class="n bad">150.00</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGVA</td><td>2026-07-03</td><td class="n">152.66</td><td class="n">40.12</td><td class="n bad">112.54</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGLK</td><td>2026-08-04</td><td class="n">482.94</td><td class="n">422.94</td><td class="n bad">60.00</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGPA</td><td>2026-06-15</td><td class="n">383.70</td><td class="n">331.19</td><td class="n bad">52.51</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGLK</td><td>2026-06-09</td><td class="n">518.88</td><td class="n">467.69</td><td class="n bad">51.19</td><td class="n good">0.00</td></tr>
</tbody>
</table>
</div>
<div class="measure">
<p>Every one overstated tip income, and in every case the correction equals the imbalance to the
cent. NGFL was crediting $238.46 of tips on a day where $168.04 had been given back.</p>
</div>
<h3>The largest service-charge repairs</h3>
<div class="scroll">
<table>
<thead><tr><th>Client</th><th>Date</th><th class="n">Service charges before</th><th class="n">After</th><th class="n">Imbalance before</th><th class="n">After</th></tr></thead>
<tbody>
<tr><td class="mono">NGPA</td><td>2026-06-04</td><td class="n bad">absent</td><td class="n">1,344.86</td><td class="n bad">+1,344.86</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NTPT</td><td>2026-08-06</td><td class="n bad">absent</td><td class="n">427.10</td><td class="n bad">+427.10</td><td class="n good">0.00</td></tr>
<tr><td class="mono">N-30003</td><td>2026-05-27</td><td class="n bad">absent</td><td class="n">405.83</td><td class="n bad">+405.83</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGPA</td><td>2026-07-02</td><td class="n bad">absent</td><td class="n">348.45</td><td class="n bad">+348.45</td><td class="n good">0.00</td></tr>
<tr><td class="mono">NGA1</td><td>2026-06-04</td><td class="n bad">absent</td><td class="n">296.35</td><td class="n bad">+296.35</td><td class="n good">0.00</td></tr>
</tbody>
</table>
</div>
<div class="measure">
<p>NGPA 2026-06-04 is the single largest repair in the ninety days: $1,344.86 of service charges
collected from customers and credited to no revenue account at all.</p>
</div>
<h3>Where both fixes land on one day</h3>
<div class="scroll">
<table>
<thead><tr><th>NGNP, 2026-06-25</th><th class="n">Before</th><th class="n">After</th><th class="n">Change</th></tr></thead>
<tbody>
<tr><td>Tip (credit)</td><td class="n">93.90</td><td class="n">92.10</td><td class="n">1.80</td></tr>
<tr><td>Service Charges (credit)</td><td class="n bad">absent</td><td class="n">301.40</td><td class="n">+301.40</td></tr>
<tr class="total"><td>Imbalance</td><td class="n bad">+299.60</td><td class="n good">0.00</td><td class="n">301.40 1.80</td></tr>
</tbody>
</table>
</div>
<div class="measure">
<p>The two corrections pull in opposite directions and still land on zero, which is a useful
check that they are independent and neither is compensating for the other.</p>
</div> </div>
</section> </section>