One bank row can now settle several vouchers: journal_entry_id stays NULL and one transaction_voucher_links row per voucher carries a signed allocated_amount slice (sum must equal the row within the link tolerance, each slice bounded by the voucher's net line on the account). linkTransactionToVouchers does the locked transaction UPDATE first and rolls back on a failed junction insert; unlink and the re-booking guards understand junction-only rows; a storno of one of the N vouchers releases the row when the remaining slices no longer sum to its amount. The worksheet's right pane becomes multi-select when exactly one bank row is picked (Koppla only at difference 0); the v1/dashboard pair schemas accept allocations; the MCP reconcile resolver and executor carry 1:N pairs; skattekonto keeps single-pointer semantics. Closes #1553
This commit is contained in:
@@ -6108,7 +6108,9 @@ async function commitBulkBookInboxItems(
|
||||
* same service the page and the v1 API use. Every pair is re-validated at
|
||||
* commit time (row still open, entry still posted and unlinked, amounts
|
||||
* close); partial success is reported in data.applied / data.skipped rather
|
||||
* than failing the whole operation, because the pairs are independent.
|
||||
* than failing the whole operation, because the pairs are independent. A
|
||||
* bank 1:N pair (one row, several verifikat, allocations) is staged as one
|
||||
* pair and re-validated as one all-or-nothing split.
|
||||
*/
|
||||
async function commitReconciliationMatch(
|
||||
supabase: SupabaseClient,
|
||||
@@ -6117,7 +6119,13 @@ async function commitReconciliationMatch(
|
||||
params: Record<string, unknown>
|
||||
): Promise<ExecutorResult> {
|
||||
const accountKey = params.account_key as string | undefined
|
||||
const pairs = params.pairs as Array<{ external_ids: string[]; journal_entry_ids: string[] }> | undefined
|
||||
const pairs = params.pairs as
|
||||
| Array<{
|
||||
external_ids: string[]
|
||||
journal_entry_ids: string[]
|
||||
allocations?: Array<{ journal_entry_id: string; amount: number }>
|
||||
}>
|
||||
| undefined
|
||||
if (!accountKey || !Array.isArray(pairs) || pairs.length === 0) {
|
||||
return { error: 'account_key and pairs are required', status: 400 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user