This commit is contained in:
seb
2026-07-31 05:43:41 +02:00
parent 09c7a8bc74
commit a57e81fe30
9 changed files with 204 additions and 122 deletions

View File

@@ -43,7 +43,15 @@ export default function create(pool) {
.query(CREATE);
await tx.commit();
return result.recordset[0].id;
return {
id: result.recordset[0].id,
root_category_id: rootCategoryId,
language_id: languageId,
taxrate: taxrateId,
reducedtaxrate: reducedtaxrateId,
taxfreerate: taxfreerateId,
};
} catch (err) {
try {
await tx.rollback();

View File

@@ -1,16 +0,0 @@
import sql from 'mssql';
import { GET_BY_COMPANY_USER_ID } from '../../sql/company.js';
export default function getByCompanyUserId(pool) {
return async (companyUserId) => {
const result = await pool
.request()
.input('companyUserId', sql.Int, companyUserId)
.query(GET_BY_COMPANY_USER_ID);
const row = result.recordset[0];
if (!row) return;
return [row.id, row.default_language_id, row.root_category_id, row.name];
};
}

View File

@@ -1,12 +0,0 @@
import sql from 'mssql';
import { SET_DEFAULT_LANG } from '../../sql/company.js';
export default function setDefaultLang(pool) {
return async (companyId, languageId) => {
await pool
.request()
.input('companyId', sql.Int, companyId)
.input('languageId', sql.Int, languageId)
.query(SET_DEFAULT_LANG);
};
}

View File

@@ -1,12 +0,0 @@
import sql from 'mssql';
import { SET_ROOT_CATEGORY } from '../../sql/company.js';
export default function setRootCategory(pool) {
return async (companyId, categoryId) => {
await pool
.request()
.input('companyId', sql.Int, companyId)
.input('categoryId', sql.Int, categoryId)
.query(SET_ROOT_CATEGORY);
};
}

View File

@@ -42,6 +42,15 @@ export default function update(pool) {
.query(UPDATE);
await tx.commit();
return {
id,
root_category_id: company.root_category_id,
language_id: languageId,
taxrate: taxrateId,
reducedtaxrate: reducedtaxrateId,
taxfreerate: company.taxfreerate,
};
} catch (err) {
try {
await tx.rollback();