Add entity customer numbers and scope APIs via selected company.

Entity gets an optional unique-per-company number with allocate/peek/isNumberFree helpers. Company-scoped store methods no longer take companyId and resolve google_auth.selected_company instead.
This commit is contained in:
seb
2026-08-07 04:29:35 +02:00
parent 1e89e19863
commit 70e0a9ddc4
78 changed files with 940 additions and 772 deletions

View File

@@ -40,7 +40,12 @@ export const TABLES = [
'meta',
];
export const PROCEDURES = ['getnextnumberwithprefixandpadding'];
export const PROCEDURES = [
'getnextnumberwithprefixandpadding',
'peeknextnumberwithprefixandpadding',
];
export const VIEWS = ['v_entity_company_number'];
/** Drop before tables — breaks company ↔ customergroup cycle for purge. */
export const CONSTRAINTS = [
@@ -54,6 +59,10 @@ export function buildPurgeSql() {
(name) =>
`IF OBJECT_ID(N'dbo.${name}', N'P') IS NOT NULL DROP PROCEDURE dbo.[${name}];`,
),
...VIEWS.map(
(name) =>
`IF OBJECT_ID(N'dbo.${name}', N'V') IS NOT NULL DROP VIEW dbo.[${name}];`,
),
...CONSTRAINTS,
...TABLES.map(
(name) =>