diff --git a/docs/2026-08-15-thirty-day-reconciliation.html b/docs/2026-08-15-thirty-day-reconciliation.html index 4a023cda..e9171bc1 100644 --- a/docs/2026-08-15-thirty-day-reconciliation.html +++ b/docs/2026-08-15-thirty-day-reconciliation.html @@ -1,17 +1,9 @@ Ninety-Day Reconciliation
-
Sales summaries · restored production backup
+
Sales summaries · measured on a restored production backup

Ninety-Day Reconciliation

-

A true baseline: the job re-run three times over ninety days — production's calculation, then each fix added — so every number below is measured output, not arithmetic.

+

Three faults were leaving restaurant days out of balance — one in the data, two in the arithmetic. This is what they were, what they cost, and what fixing them is worth, measured by running the real job over ninety days of real trading.

Window 2026-05-10 → 2026-08-07 - Client-days 8,733 with activity + Client-days 8,733 Clients 106 - Most recent week omitted + Nothing in production was changed
- Baseline - $58,531.75 - 1,024 days out of balance · 87.74% clean + Production today + $75,228.78 + 1,280 days out of balance · 85.34% clean
- After both fixes - $852.38 - 105 days out of balance · 98.74% clean + After all three fixes + $1,995.36 + 108 days out of balance · 98.76% clean
-
919client-days brought into balance
+
1,172client-days brought into balance
0days knocked out of balance
-
0balanced days whose numbers moved
-
98.5%of the dollar variance removed
+
97.3%of the variance removed
+
0shared payment records left
-

Figures exclude the ten deactivated duplicate clients, which the plan says to exclude from reporting. Across the full 8,733 client-days including them the shape is the same: 1,087 → 108 days out of balance, $63,764.92 → $1,995.36.

+

In one sentence: a day's sales summary should show the money taken and the money earned agreeing to the penny, and on roughly one day in seven it did not — because two clients were fighting over the same records, tips that had been refunded were still counted as income, and service charges customers paid were credited to nothing.

-

Why this baseline is different

-
-

The earlier thirty-day report derived its baseline arithmetically. This one does not. The job was run three separate times over the same ninety days, against the same data, writing real summaries each time:

-
    -
  • Run A — baseline. The service-charge flag cleared on all 210 clients and get-tip restored to its tendered-only form. This is exactly what production calculates today.
  • -
  • Run B — plus R1. Only get-tip changed.
  • -
  • Run C — plus R2. The service-charge flag switched on as well.
  • -
-

The underlying data — Phase 0, the re-key, the repaired charge references — is identical across all three, so what separates them is the calculation and nothing else. 18,900 summaries were written per run, 56,700 in total.

-

The most recent week (08-08 → 08-14) is excluded deliberately. The backup was cut mid-evening on the 14th, and the days either side of that are partial, which distorted the earlier window.

+

The three problems

+ +
+

1. Two client records sharing one Square location

+
+

For the business: ten restaurant locations were set up twice in the system, as two separate clients. Both were importing from Square. Because the two records competed for the same payments and refunds, a refund would belong to one client for twenty minutes, then the other — so a day's books could gain or lose a refund depending on nothing but timing. On 2026-07-23 one client's summary was missing a $71.94 refund entirely, and was out of balance by exactly that amount.

+

technical Sales orders scoped their identifier by client (square/order/<code>-<loc>-<id>), but refunds, card charges, payouts and cash-drawer shifts did not — they used the bare Square id. Those attributes are :db.unique/identity, so both clients' imports resolved to a single entity and the last writer won.

+

Reading ownership out of the database's own history, this had actually happened to 3,387 refunds, 4,069 payouts and 2,628 cash-drawer shifts. And it has involved 19 client pairs, of which only 10 are visible in today's configuration — nine more contended in the past and the configuration has since changed, so no point-in-time check would find them.

+
+
+ +
+

2. One payment record owned by two orders

+
+

For the business: the same collision meant a single card payment could be attached to both clients' copies of an order. That is worse than untidy. The nightly import removes orders Square reports as voided, and removing an order also removes its payments — so cancelling one client's order could silently delete the other client's payment, leaving a day showing sales with no money against them.

+

technical :sales-order/charges is declared :db/isComponent true, so [:db/retractEntity <order>] cascades into the charges. In a 20,000-order sample of the affected clients, 11,469 charges had two parent orders. This is why remove-voided-orders was left switched off during testing.

+
+
+ +
+

3. Tips refunded, and service charges credited nowhere

+
+

For the business: two arithmetic faults, both of which overstated or understated a day.

+
    +
  • Refunded tips stayed on the books. When a guest was refunded, the tip came back too — but the summary still counted the original tip as income. On one NGLK day the books credited $482.94 of tips beside a $60.00 refund of that very tip.
  • +
  • Service charges were collected but never earned. A catering or auto-gratuity charge is inside the card payment the customer makes, so it arrived as money taken — but no line recorded it as money earned. One NTPT order carried $427.10 that was credited to nothing at all; the largest single instance was $1,344.86 in one day.
  • +
+

technical get-tip summed tips by joining through :sales-order/charges, so a return-only order — which has no tender to join through — contributed nothing, while its reversal sat unread on :sales-order/tip. Nothing at all read :sales-order/service-charge.

+
-

Impact by underlying fix

+

What each fix is worth

-

Applied in sequence, each measured against the run before it, over 8,350 reportable client-days.

-
- -
-

R1

-
Tips on untendered orders
+

The job was run over the same ninety days at each stage, writing real summaries every time, so these are measured outcomes rather than estimates.

- + - - - - - - + + + +
OutcomeClient-daysShare
StageDays out of balanceCleanTotal variance
Unchanged8,05496.5%
Out of balance → balanced2723.3%
Balanced → out of balance0
Balanced → balanced, numbers changed0
Still out of balance, but closer240.3%
Days touched · dollars moved296$3,623.44
Production today1,28085.34%$75,228.78
+ deduplication1,08787.55%$63,764.92
+ refunded tips80090.84%$60,619.21
+ service charges10898.76%$1,995.36
-
-

R2

-
Square service charges, both signs
-
+

Day-by-day effect of each change

- + - - - - - - + + + +
OutcomeClient-daysShare
ChangeUnchangedInto balanceOut of balanceBalanced days alteredMoney moved
Unchanged7,70192.2%
Out of balance → balanced6477.7%
Balanced → out of balance0
Balanced → balanced, numbers changed0
Still out of balance, but closer2<0.1%
Days touched · dollars moved649$54,775.79
Deduplication7,447 balanced already1996
Refunded tips8,42128700$3,777.67
Service charges8,03769200$58,923.85
All three, end to end7,4531,17200
- -

Both together, full population

-
- - - - - - - - - - -
OutcomeClient-days
Unchanged7,749
Out of balance → balanced979
Balanced → out of balance0
Balanced → balanced, numbers changed0
Still out of balance, but closer5
Days touched · dollars moved984 · $62,069.64
-
- -
- Neither fix touches a healthy day — now confirmed over three times the window -

Across 8,733 client-days and 90 days of trading, not one day that balanced under production's calculation was altered by either fix: zero knocked out of balance, and zero whose amounts moved while staying balanced. Every day they touched was already out of balance. The thirty-day run found the same thing; this replicates it on a much larger sample.

+
+

Neither arithmetic fix touched a day that was already correct. Across 8,733 client-days, no balanced day was knocked out of balance and no balanced day had a single figure altered — every day they changed was already wrong. Service charges are by far the larger of the two, moving $58,923.85 against the tip fix's $3,777.67.

+

Deduplication is the one step that puts six days out of balance. That is expected: those days were previously balanced only because a summary was empty, and filling it in exposes the same arithmetic faults every other day had. Both later fixes then close them, which is why the end-to-end figure is zero.

+

Excluding the ten now-deactivated duplicate records, which should not be reported on at all, the population is 8,350 client-days and the movement is 1,217 days and $69,995.61 down to 105 days and $852.38.

-

What actually changed on the page

+

What it looks like on the page

-

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.

+

Both arithmetic fixes add exactly one credit line. Nothing else in a summary moves — no sales figure, no payment, no tax.

-

R1 — NGLK, 2026-08-04

+

A refunded tip — NGLK, 2026-08-04

- + - - - - - - + + + + +
LineBeforeAfterChange
LineBeforeAfter
Tip (credit)482.94422.94−60.00
Card Refunds (credit)60.0060.00
every other lineunchanged
Total debits10,094.8110,094.81
Total credits10,154.8110,094.81−60.00
Imbalance−60.000.00balanced
Tip482.94422.94
Card Refunds60.0060.00
Total money taken10,094.8110,094.81
Total money earned10,154.8110,094.81
Out of balance by−60.000.00
-

Read the two credit lines together and the story is complete: the day already carried a - $60.00 card refund — 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 get-tip 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.

+

The day already carried a $60.00 card refund — the guest was given their money back, tip included — while the tip line still credited the full $482.94. The corrected figure matches the refund to the penny. The order behind it is square/order/NGLK-SM-OxSX9gpXJV394qqT8mnBGypUwKNZY: a tip of −60.00 on an order with no payment attached at all.

-

R2 — NTPT, 2026-08-06

+

A service charge — NTPT, 2026-08-06

- + - - - - - - + + + + + + +
LineBeforeAfterChange
LineBeforeAfter
Service Charges (credit)absent427.10+427.10
Card Payments (debit)4,975.894,975.89
every other lineunchanged
Total debits7,777.207,777.20
Total credits7,350.107,777.20+427.10
Imbalance+427.100.00balanced
Service Chargesnot shown427.10
Card Payments4,975.894,975.89
Total money taken7,777.207,777.20
Total money earned7,350.107,777.20
Out of balance by+427.100.00
+
+ +

The largest repairs of each kind

+
+ + + + + + + + +
ClientDateLineBeforeAfterDay closed
NGPA2026-06-04Service Chargesnot shown1,344.86+1,344.86 → 0
NTPT2026-08-06Service Chargesnot shown427.10+427.10 → 0
N-300032026-05-27Service Chargesnot shown405.83+405.83 → 0
NGFL2026-05-19Tip238.4670.42−168.04 → 0
NGMI2026-07-09Tip230.0180.01−150.00 → 0
NGVA2026-07-03Tip152.6640.12−112.54 → 0
-

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 - square/order/NTPT-PT-KrMZzcon1cpQEJUyetErkBIpcdEZY, carrying a - :sales-order/service-charge of 427.10 on a 3,198.78 order.

-
- -

The largest tip repairs

-
- - - - - - - - - - -
ClientDateTip beforeTip afterImbalance beforeAfter
NGFL2026-05-19238.4670.42−168.040.00
NGMI2026-07-09230.0180.01−150.000.00
NGVA2026-07-03152.6640.12−112.540.00
NGLK2026-08-04482.94422.94−60.000.00
NGPA2026-06-15383.70331.19−52.510.00
NGLK2026-06-09518.88467.69−51.190.00
-
-
-

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.

-
- -

The largest service-charge repairs

-
- - - - - - - - - -
ClientDateService charges beforeAfterImbalance beforeAfter
NGPA2026-06-04absent1,344.86+1,344.860.00
NTPT2026-08-06absent427.10+427.100.00
N-300032026-05-27absent405.83+405.830.00
NGPA2026-07-02absent348.45+348.450.00
NGA12026-06-04absent296.35+296.350.00
-
-
-

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.

-
- -

Where both fixes land on one day

-
- - - - - - - -
NGNP, 2026-06-25BeforeAfterChange
Tip (credit)93.9092.10−1.80
Service Charges (credit)absent301.40+301.40
Imbalance+299.600.00301.40 − 1.80
-
-
-

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.

+

In every case the correction equals the imbalance exactly, which is what you would expect if the fix is recording something real that was recorded nowhere. On NGNP 2026-06-25 both fixes land on one day and pull opposite ways — $301.40 credited, $1.80 removed, $299.60 closed — a useful check that they are independent.

-

What is left

+

What was done to the data, and how it was checked

-

Fifteen client-days above the ten-cent materiality threshold, out of 8,350. Everything else — 90 client-days — totals $2.26.

+

Every step below was performed against a restored copy of the production database. Production itself was never touched.

-
- - - - - - - - - - - - - - - - - - - -
ClientDateVarianceNote
NGBK2026-08-06+299.42tender exceeds order totals by exactly this much
NGMV2026-05-24+100.87a five-day cluster in late May, new to this window and not yet diagnosed
NGMV2026-05-20+72.05
NGMV2026-05-21+57.64
NGMV2026-05-22+14.41
NGMV2026-05-26+14.41
NGEB2026-05-19−79.01ezCater fee semantics — the plan's open question §15.4
NGEB2026-06-23−50.28
NGEB2026-05-13−49.80
NGEB2026-07-29−20.00
NGDA2026-08-01−50.00auto-gratuity booked as a service charge
N-300122026-05-20+17.32two consecutive days, undiagnosed
N-300122026-05-21+12.99
NG4S2026-05-29−11.78undiagnosed
PNSP2026-07-12−0.14register rounding, just over threshold
-
-
-

Widening from thirty days to ninety surfaced two clusters the shorter window could not see: NGMV across five days in late May, and NGEB across four days spanning May to July. NGEB is the known ezCater fee-semantics question. NGMV and N-30012 are new and worth a look before this ships — they are the kind of thing only a longer baseline exposes.

-

The ten deactivated twins, excluded above, contribute a further $1,142.98 across three days. They should not be reported on at all once one client per location is settled.

-
-
- -
-

Two performance defects found on the way

-
-

Running the job 56,700 times surfaced two problems that a normal nightly pass would hide, both now fixed or documented.

-
-
- - - - - - -
ProblemEffectFix
dirty-sales-summaries scanned the whole index1,321 ms → 5.6 ms per clientbound the scan at the client boundary
Transactor sized for a toy database~35/min → 5,300/minobject cache 2 GB → 8 GB, heap 4 GB → 16 GB
-
-
-

The second is a deployment setting rather than a code change, but it is dramatic: with a 2 GB object cache against a 27 GB database, the final 7,958 client-days of a pass were crawling at about 35 a minute. After resizing they completed in 90 seconds. Worth checking what production's transactor is sized at.

-
-
- -
-

Reproduce it

-
-
;; connect to the restored backup
-(def conn (d/connect "datomic:dev://localhost:4337/integreat-prod-restore"))
-
-;; baseline mode: clear the flag, restore tendered-only tips
-(doseq [[c _] clients]
-  @(d/transact conn [[:db/retract c :client/feature-flags "summary-service-charges"]]))
-(alter-var-root #'ss/get-tip (constantly baseline-get-tip))
-
-;; mark the window and run the real job, then capture
-(doseq [[c _] clients] (ss/mark-dirty c w90-start w90-end))
-(pmap (fn [[c code]] (ss/refresh-client! c code)) pending)
-
-;; the single orders behind the worked examples
-(d/pull (d/db conn) '[*]
-        [:sales-order/external-id
-         "square/order/NGLK-SM-OxSX9gpXJV394qqT8mnBGypUwKNZY"])
-(d/pull (d/db conn) '[*]
-        [:sales-order/external-id
-         "square/order/NTPT-PT-KrMZzcon1cpQEJUyetErkBIpcdEZY"])
-
-
-

The unit tests covering both fixes and the re-key:

-
-
-
lein test auto-ap.jobs.sales-summaries-test auto-ap.square.core3-test
-;; => 15 tests, 26 assertions, 0 failures
-
-
- Two defects still open before this ships -

Re-keying a charge that has two parent orders duplicates the tender, because the other client's import then matches neither key and creates a second charge which cardinality-many appends. The migration must split shared charges first. Separately, remove-voided-orders retracts orders, and 63% of the contended clients' charges have two parents, so a retraction there deletes the other client's payment.

-
-
- -
-

Isolation: which entities could still swap owners

-
-

Balancing was only half the problem. The other half is whether an entity can change hands - between two clients at all. Rather than reason about it, every entity type the importers - create with a unique external id was audited, and ownership was read out of the database's - own history.

-
- -

Entities whose client has actually changed

-
- - - - - - - - -
EntitySwappedOf totalKey before
Expected deposits (Square payouts)4,069144,688square/payout/<id>
Cash drawer shifts2,62869,291square/cash-drawer-shift/<id>
Refunds3,38751,990fixed earlier
Sales orders, ezCater orders0already scoped
-
-
-

Both payout and cash-shift endpoints are filtered by location, so two clients configured on - one Square location import the same records and collide on a single entity — the identical - defect refunds and charges had, in two types nobody had looked at.

-
- -
- Nineteen client pairs have contended, but only ten are visible today -

Nine pairs no longer share a location in the current configuration, so no point-in-time - check would find them — yet their data is still mixed. The largest are NGMJ/NGSC with 1,546 - affected entities, NGAK/NGMH with 952, NGBW/NGWD with 780 and NGNP/NGVZ with 645. This is the - argument for scoping the keys rather than only deactivating what currently looks shared: - deactivation is a snapshot fix that rots the next time someone configures a location twice.

-

Worth knowing alongside it: 105 of the clients share a single Square auth token, - so these importers all reach into one Square account. The blast radius of a future - misconfiguration is the estate, not a pair.

-
- -

What was done, and what it cost the books

- - - - - - - + + + + + +
StepResult
Re-key expected deposits144,652 re-keyed · 0 collisions · 36 unscopable
Re-key cash drawer shifts69,291 re-keyed · 0 collisions · 0 unscopable
Entity counts before vs afterunchanged on all four types
Legacy-scheme keys remaining0
Live re-import, 66 of 102 clients, 90-day window0 entities created · 0 values rewritten
Ownership changes since the re-key0 deposits · 0 shifts · 0 refunds
Summaries recomputed and compared18,900 · 0 differences
Deactivate the duplicate client at each shared location10 locations · shared locations remaining: 0
Give every order its own payment record189,167 re-keyed · 77,599 copied
Payments owned by two orders11,469 → 0
Client-scope refunds, payouts and cash-drawer shiftscounts unchanged · 0 collisions
Live Square import afterwards0 orders with duplicated payment · 0 shared payments
Ownership changes after the change0 refunds · 0 payouts · 0 shifts
-

The re-import is the important negative result. Every payout and shift the importer fetched - resolved to the client's own entity and wrote nothing — the re-key is transparent to the - importer, which is exactly what the legacy-key fallback is for. And recomputing all 18,900 - client-days afterwards reproduced the previous figures exactly — largest difference 0.000000, so re-keying 213,943 - entities moved no money at all.

-

One caveat worth stating plainly: re-keying stops future contention, but it does not - retrospectively re-attribute records that were claimed by the wrong client while the - configuration was shared. Those stay where they were last written. Correcting them is a - separate exercise, and one to do only once the business decides which client owns each - location.

+

The count checks are the ones that matter. If re-keying had gone wrong it would have created a second copy of every record rather than updating the existing one, and the totals would have doubled. They did not move. The payment-copy step is the exception and is meant to add records — it added exactly 77,599, matching the number of copies it reported making.

+
+ +
+ A bug in this work, found by measuring rather than reading +

The first attempt at copying shared payments derived each payment's Square identifier by stripping a fixed prefix. That is right the first time a payment is seen, but once it has been re-keyed to one client, a second order meeting it later read the already-scoped key as the identifier and scoped it twice — NGCD-CD-NGCC-CC-<id>. The importer then created a fresh payment, doubling the tender on five clients by $3,000–$7,000 each. It was caught because the totals were absurd, not because the code looked wrong. The fix recovers the scope from the record itself; client codes contain dashes, so it cannot be done by pattern. A test now runs the step one order at a time, which is the arrangement that exposes it.

-

Why remove-voided-orders is dangerous

+

What is still out of balance

-

The schema says a charge belongs to its order:

+

Fifteen client-days across ninety days and 8,350 client-days, totalling $850.12. Everything else — 90 further days — comes to $2.26, the largest being 9.00¢, which is till rounding.

-
{:db/ident :sales-order/charges, :db/isComponent true}
+ + + + + + + + + + + +
ClientDateVarianceWhat it is
NGBK2026-08-06+299.42Square recorded more payment than the orders account for
NGMVMay 20–26+259.38five days, undiagnosed
NGEBMay 13 – Jul 29−199.09four days, ezCater fee treatment — an open question
NGDA2026-08-01−50.00auto-gratuity recorded as a service charge
N-30012May 20–21+30.31two days, undiagnosed
NG4S2026-05-29−11.78undiagnosed
PNSP2026-07-12−0.14till rounding, just over the threshold
-

:db/isComponent means Datomic treats charges as parts of the order rather - than independent records. So [:db/retractEntity <order>] deletes the order - and its charges. That is the documented behaviour, and normally it is what you want.

-

remove-voided-orders asks Square for the last ten days of orders, keeps the ones - Square reports as voided, and retracts them. Correct on its own terms.

-

The problem is that where two clients shared a location, both clients' orders resolved to the - same charge entity, because charge keys carried no client:

+

The ten deactivated duplicate records contribute a further $1,142.98 across three days. They are excluded above and should be excluded from reporting generally, since they are now dormant copies.

+

Two clusters — NGMV and N-30012, both in late May — are new and unexplained. They only became visible because the window was widened to ninety days; a thirty-day view did not reach them. They are worth a look before this ships.

+
+ +
+

Decisions and risks still open

-
NGCD order ──┐
-             ├──> charge 17592490524   ← one entity, two parents
-NGCC order ──┘
+ + + + + + + + +
ItemWho decidesWhy it matters
Which client record survives at each shared locationthe businessthe newer record generally has no history before the split, so keeping it loses years of the location's books
Which revenue account service charges post toaccountingcurrently 49000 Service Income, chosen so the work could be measured; it affects reporting, never whether a day balances
Whether to correct records the wrong client already ownsthe businessthe fix stops future mix-ups; it does not retrospectively move records claimed while the configuration was shared
remove-voided-ordersengineeringsafe once no payment has two parent orders; worth guarding regardless so it detaches rather than deletes
+
+ +
+ Two operational findings, unrelated to the summaries +

The production backup had not written a restore point since 2025-03-10 — roughly seventeen months — even though data files were still uploading daily. A backup you cannot restore from is not a backup. A fresh one was taken on 2026-08-14 and is what this work used.

+

The database server was sized for a toy dataset: a 2 GB cache against 27 GB of data. A recompute was crawling at about 35 client-days a minute; after raising the cache to 8 GB the remaining 7,958 finished in 90 seconds. Worth checking what production is set to.

+
+
+ +
+

How to check any of this technical

+
+
;; the restored database, untouched production as of 2026-08-14 22:52
+(def conn (d/connect "datomic:dev://localhost:4337/integreat-prod-restore"))
+
+;; the two orders behind the worked examples
+(d/pull (d/db conn) '[*] [:sales-order/external-id
+                          "square/order/NGLK-SM-OxSX9gpXJV394qqT8mnBGypUwKNZY"])
+(d/pull (d/db conn) '[*] [:sales-order/external-id
+                          "square/order/NTPT-PT-KrMZzcon1cpQEJUyetErkBIpcdEZY"])
+
+;; the gate: no payment may have two parent orders
+(rk/charges-with-multiple-parents (d/db conn) orders)   ;; => 0
+
+;; ownership history — which records ever changed client
+(->> (d/datoms (d/history (d/db conn)) :aevt :sales-refund/client)
+     (filter :added)
+     (reduce (fn [m d] (update m (:e d) (fnil conj #{}) (:v d))) {})
+     (filter (fn [[_ owners]] (> (count owners) 1)))
+     count)
-

Retract either order and Datomic deletes that shared charge. The other client's order survives - with its sales intact but its payment gone: the day silently goes out of balance and the tender - disappears from the current database value. Measured on the restore, - 35,870 of 56,829 charges (63%) in the contended clients' recent window have two - parent orders.

-

The re-key stops new sharing but does not un-share those. Two remedies, either sufficient: - split them by re-importing the affected window now that keys are client-scoped, or guard the - retraction so it detaches a shared charge instead of deleting it. The guard is small and makes - the operation safe whatever shape the data is in.

+

The comparison tool is committed as auto-ap.jobs.compare-sales-summaries, which diffs summaries between two points in the same database using as-of — so "before" is production's own stored figures rather than a re-simulation. Unit tests: lein test auto-ap.jobs.sales-summaries-test auto-ap.square.core3-test auto-ap.jobs.rekey-square-external-ids-test.