QBO Bill Account Mapping Engine#110
Open
hhff wants to merge 26 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tributor rows Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The schema dumper materializes the three composite FKs to qbo_invoices as single-column add_foreign_key lines (lossy/incorrect); origin keeps them as comments. Restore after the qbo_chart_accounts migration regenerated the file. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… rows Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ation Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ubject labels Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… precedence Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rror path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…a the mapping engine Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…CP sync Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ouping Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ping form Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Replaces the hard-coded QBO account routing for every Stacks-managed bill (ContributorPayout, Trueup, ContributorAdjustment, ProfitShare, PayStub) with a database-backed mapping engine:
QboChartAccount— local mirror of each realm's chart of accounts (synced daily, on-demand via a new "Refresh Chart of Accounts" admin action, and lazily on first bill sync). The enterprise dashboard now reads balances from the mirror instead of a live QBO fetch per page load.QboBillAccountMapping— one rules table:(enterprise, line_item_key, subject)→ chart account, where subject is a ProjectTracker, Contributor, or null for the entity default, across ten line-item kinds (six payout buckets, trueup, adjustment, profit share, pay stub).Qbo::BillAccountResolver— single resolution path: project tracker → contributor → entity default, raisingQbo::UnmappedLineItemErrorwhen unmapped (no silent fallbacks). All legacy routing (find_qbo_account!overrides,SPECIFIC_ACCT_NUM_BY_BUCKET,PROFIT_SHARE_LIABILITY_ACCT_NUM,Studio#qbo_subcontractors_categories, the internal-client Marketing conditional) is deleted.Qbo::SeedBillAccountMappings+rake stacks:seed_qbo_bill_account_mappings— idempotent seeding that reproduces today's behavior exactly (entity defaults, studio routing snapshotted to contributor rows, internal-client trackers → Marketing), with per-enterprise error isolation.unmappedindicators, and override sidebars on ProjectTracker and Contributor pages.Design doc:
docs/superpowers/specs/2026-06-10-qbo-bill-account-mapping-engine-design.md(decision notes cover the accepted behavior deviations). Implementation plan:docs/superpowers/plans/2026-06-10-qbo-bill-account-mapping-engine.md.Rollout
rake stacks:seed_qbo_bill_account_mappingsimmediately — until it runs, bill syncs fail per-record withQbo::UnmappedLineItemError(isolated in the nightly loop, flashed in admin; nothing blocks, but it's noisy). Review the created/skipped output per enterprise.unmappedtags (or deliberately leave kinds that enterprise never bills).Qbo::UnmappedLineItemErrorand chart-sync deactivation warnings over the first daily run.Data checks worth doing before/at deploy
is_internal?? (Seeded internality is scoped to the owning enterprise.)Test Plan
🤖 Generated with Claude Code