feat(treasury): open-document sweep + auto commitment matching in Xero sync - #400
Open
adme-dev wants to merge 1 commit into
Open
feat(treasury): open-document sweep + auto commitment matching in Xero sync#400adme-dev wants to merge 1 commit into
adme-dev wants to merge 1 commit into
Conversation
…o sync The invoice sync's delta path windows on modified time, so open bills entered before the cache was first warmed never landed (observed: cache floor ~20 Jul 2026; Bossio Dec-25 and WIN TV May-26 bills invisible). Treasury and the commitment matcher read this cache, so 'absent' had to be verified in Xero by hand. - Add an open-document sweep after the delta pass: pages AUTHORISED/ SUBMITTED/DRAFT docs per type with no If-Modified-Since, no date floor. ~1 extra call per type per run; quota-neutral (PR #381 regime). - Run the commitment matcher (auto tier only) inside fullCustomerSync so register estimates are superseded by real bills every sync cycle, not just when someone hits the manual match endpoint. Suggested-tier still requires human confirmation. - commitmentsMatched added to XeroSyncResult. Workstream W1 of .paul/PLAN-2026-08-13-spreadsheet-retirement-platform-work.md (spreadsheet retirement, Monday board C-12). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Parallel-run week 1 of the spreadsheet retirement (Monday board C-09/C-12) showed the invoice cache is windowed: the delta sync filters on modified time, so open bills entered before the cache was first warmed (floor ~20 Jul 2026) never land. Bossio's Dec-25 instalment bill and the WIN TV May-26 draft are in Xero but invisible to Treasury — which meant "absent from cache" could not be trusted to mean "absent from Xero", and forecast commitments could double-count real bills.
What
syncXeroInvoicesCache: after the delta pass, pageAUTHORISED/SUBMITTED/DRAFTdocuments per type with noIf-Modified-Sinceand no date floor. Open docs number in the dozens → ~1 extra API call per type per run, negligible under the post-fix: stop xero-customer-sync burning the 5,000/day Xero API quota #381 quota regime.fullCustomerSync: runs the existingcommitmentMatcher(merged earlier) every sync cycle, applyingauto-confidence matches only (contact/exact-name + amount ±1% + date ±30d).suggestedmatches still require a human viaPOST /api/cashflow/commitments/match. NewcommitmentsMatchedfield onXeroSyncResult.upsertedIds) so delta + sweep never double-upsert.Tests
test/server/utils/xeroOpenDocsSweep.test.ts: sweep catches an open bill older than the delta window; sweep queries filter to open statuses without the delta header; no double-upsert across passes.test/server/utils/suite: 2,865 passed.Context
Workstream W1 of
.paul/PLAN-2026-08-13-spreadsheet-retirement-platform-work.md. W3 (treasury policy layer) and W2 (RepeatingInvoices push, gated on Kellie + accountant decisions, target 27 Aug) follow.🤖 Generated with Claude Code