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

@@ -0,0 +1,19 @@
import { ENSURE_TYPE } from '../../sql/numbers.js';
import request from '../request.js';
export default function peekNumber(pool) {
return async (companyId, type, tx) => {
await request(pool, tx)
.input('companyId', companyId)
.input('type', type)
.query(ENSURE_TYPE);
const req = request(pool, tx);
req.input('company_id', companyId);
req.input('type', type);
req.output('value');
const result = await req.execute('peeknextnumberwithprefixandpadding');
return result.output.value;
};
}