Repository navigation
Bexio expense sync: only handle purchases with status=pending - #29
Merged
Merged
Conversation
Moco purchases move pending -> archived once the operator has filed
them. An archived purchase is closed business and must not be (re-)pushed
to Bexio, but every later edit of one still fires a Purchase:update
webhook at us.
Gate on `status` as the very first check in `sync()`, ahead of the
"Review pending" tag: anything that isn't `pending` returns
`{"skipped": "status_not_pending", "status": ...}` with an INFO log and
no Telegram alert (the webhooks repeat, so alerting would be noise), and
the endpoint's usual 200/ok=true stops Moco retrying.
The gate is pending-only rather than archived-only so a status Moco grows
later can't be silently treated as payable. A body carrying no `status`
at all still syncs: every live webhook has the field, and dropping a real
bill because some shape omitted it is the worse failure than syncing one
purchase too many.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014tmj9oSBu9dBe7yBoS4TTs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
What
/api/bexio-expense-syncnow processes a Moco purchase only when itsstatusispending. Anything else — an archived purchase above all — is skipped silently.Why
Moco purchases move
pending→archivedonce the operator has filed them. An archived purchase is closed business and must not be (re-)pushed to Bexio, but every later edit of one still fires aPurchase:updatewebhook at us.How
New first gate in
sync(), ahead of the "Review pending" tag check:Three decisions worth calling out:
ok=trueso Moco stops retrying (same shape as the other routine skips).pending-only, notarchived-only, so a status Moco grows later can't be silently treated as payable._purchase_statuslowercases and trims first.statusstill syncs. All five live-webhook fixtures carrystatus: "pending", but the OCR auto-release hand-off feedsget_purchaseoutput into the samesync(); silently dropping a real bill because some shape omitted the field is the worse failure than syncing one purchase too many.Tests
Four new cases in
tests/test_bexio_expense_sync_service.py— archived skips with zero Bexio/Moco I/O and no Telegram, the casing/other-status sweep,pendingstill syncing end-to-end, and a status-less body still syncing. Full suite: 691 passed.CLAUDE.md's service bullet updated in the same commit.
🤖 Generated with Claude Code
https://claude.ai/code/session_014tmj9oSBu9dBe7yBoS4TTs