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:
@@ -1,5 +1,5 @@
|
||||
import { GET_BY_ID, SET_OFF, LIST_CATEGORY_IDS } from '../../sql/posterminal.js';
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
|
||||
|
||||
/**
|
||||
* Removes a category assignment from a posterminal (turns it off).
|
||||
@@ -9,18 +9,18 @@ import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
*
|
||||
* @example
|
||||
* const fn = setOff(pool);
|
||||
* const result = await fn(42, 1, 5, 9);
|
||||
* const result = await fn(42, 5, 9);
|
||||
* // => { id, categoryIds: [...] }
|
||||
*/
|
||||
export default function setOff(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
const access = resolveSelectedCompanyAccess(pool);
|
||||
|
||||
return async (googleAuthId, companyId, posterminalId, categoryId) => {
|
||||
return async (googleAuthId, posterminalId, categoryId) => {
|
||||
if (!Number.isFinite(posterminalId) || !Number.isFinite(categoryId)) {
|
||||
throw new Error('Invalid posterminal or category');
|
||||
}
|
||||
|
||||
await access(googleAuthId, companyId);
|
||||
const { companyId } = await access(googleAuthId);
|
||||
|
||||
const existing = await pool
|
||||
.request()
|
||||
|
||||
Reference in New Issue
Block a user