feat(recurring): carry dimension bags on recurring invoice schedules (#1272)

Schedules and their template items now store {sie_dim_no: code} bags
(default_dimensions / dimensions), and the cron generator copies them
onto every spawned invoice + item, so recurring invoices book with the
same projekt/kostnadsstalle tags a manual invoice would. Wired through
the web CRUD routes, the staged-operation executors, and the MCP
create/update/list schedule tools (resolve-don't-select, resolutions
echoed in the preview).

Migration 20260728090000 adds the two jsonb columns (same shape+CHECK
as invoices/invoice_items, PR7 producer parity).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-29 09:38:52 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 65c6d4c178
commit 951b33363b
12 changed files with 539 additions and 6 deletions
+5 -1
View File
@@ -548,6 +548,7 @@ async function commitCreateRecurringSchedule(
our_reference: validated.our_reference ?? null,
notes: validated.notes ?? null,
auto_send: validated.auto_send,
default_dimensions: validated.default_dimensions ?? {},
next_run_date: nextRunDate,
status: 'active',
})
@@ -566,6 +567,7 @@ async function commitCreateRecurringSchedule(
unit: item.unit,
unit_price: item.unit_price,
vat_rate: item.vat_rate ?? null,
dimensions: item.dimensions ?? {},
}))
const { error: itemsError } = await supabase
@@ -707,7 +709,7 @@ async function commitUpdateRecurringSchedule(
// and silently skip billing dates.
const { data: previousItems } = await supabase
.from('recurring_invoice_schedule_items')
.select('sort_order, description, quantity, unit, unit_price, vat_rate')
.select('sort_order, description, quantity, unit, unit_price, vat_rate, dimensions')
.eq('schedule_id', scheduleId)
await supabase
@@ -723,6 +725,7 @@ async function commitUpdateRecurringSchedule(
unit: item.unit,
unit_price: item.unit_price,
vat_rate: item.vat_rate ?? null,
dimensions: item.dimensions ?? {},
}))
const { error: itemsError } = await supabase
@@ -740,6 +743,7 @@ async function commitUpdateRecurringSchedule(
unit: row.unit,
unit_price: row.unit_price,
vat_rate: row.vat_rate,
dimensions: row.dimensions ?? {},
}))
const { error: restoreError } = await supabase
.from('recurring_invoice_schedule_items')