fix: SIE import voucher range bugs + remove describe transaction (#161)

* fix: fix SIE import voucher range bugs from multi-tenant migration and remove describe transaction feature

- Fix reserve_voucher_range RPC parameter mismatch (p_user_id → p_company_id) causing duplicate voucher errors
- Fix create-accounts onConflict from user_id to company_id
- Add reserve-then-adjust pattern: pre-reserve voucher range before batch insert, release unused range on partial failure
- Add release_voucher_range DB function for safe rollback
- Remove DescribeTransactionDialog, describe/batch-describe API routes, and related schemas (feature superseded)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Greptile review — voucher range race condition and orphaned entries

- Add p_reserved_highest upper-bound guard to release_voucher_range to prevent
  rolling back past numbers claimed by concurrent operations
- Move highestInsertedVoucher tracking to after both headers AND lines succeed,
  preventing orphaned journal entries with no lines from being counted as "used"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-04-02 10:48:13 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 197beb1c58
commit 9dceb6285c
12 changed files with 103 additions and 1635 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ export async function POST(request: Request) {
const { data: upserted, error } = await supabase
.from('chart_of_accounts')
.upsert(batch, {
onConflict: 'user_id,account_number',
onConflict: 'company_id,account_number',
ignoreDuplicates: true,
count: 'exact',
})