This commit is contained in:
seb
2026-07-31 07:22:34 +02:00
parent 02bca8e236
commit bbd69e8c7c
29 changed files with 144 additions and 87 deletions

View File

@@ -70,9 +70,9 @@ const MENU = {
company: {
label: 'company',
items: [
{ value: 'company.create', label: 'create', hint: 'iso639,name,taxes → result' },
{ value: 'company.create', label: 'create', hint: 'authId, iso639, name, taxes → result' },
{ value: 'company.update', label: 'update', hint: 'id + fields → result' },
{ value: 'company.list', label: 'list', hint: '→ result[]' },
{ value: 'company.list', label: 'list', hint: 'authId → result[]' },
{ value: 'company.delete', label: 'delete', hint: 'companyId' },
],
},
@@ -178,25 +178,25 @@ async function runMethod(client, action) {
const reducedtaxrate = await askNumber('Reduced tax rate', '7');
if (reducedtaxrate == null) return;
const existing = await client.google_auth.getByEmail(email);
const authId = existing
? existing.id
: await client.google_auth.add(email);
const created = await client.company.create({
iso639,
name,
taxrate,
reducedtaxrate,
authId,
});
const companyId = created.id;
const existing = await client.google_auth.getByEmail(email);
const authId = existing
? existing.id
: await client.google_auth.add(email);
const companyUserId = await client.companyuser.add(companyId, authId);
await client.google_auth.setSelectedCompany(authId, companyId);
return [
'created',
{
...created,
companyUserId,
authId,
email,
name,
@@ -207,6 +207,8 @@ async function runMethod(client, action) {
];
}
case 'company.create': {
const authId = await askInt('google_auth id');
if (authId == null) return;
const name = await askText('Name', {
placeholder: 'Acme',
validate: (v) => (!v?.trim() ? 'Required' : undefined),
@@ -223,7 +225,13 @@ async function runMethod(client, action) {
if (reducedtaxrate == null) return;
return [
'result',
await client.company.create({ iso639, name, taxrate, reducedtaxrate }),
await client.company.create({
iso639,
name,
taxrate,
reducedtaxrate,
authId: Number(authId),
}),
];
}
case 'company.update': {
@@ -254,7 +262,9 @@ async function runMethod(client, action) {
];
}
case 'company.list': {
return ['result[]', await client.company.list()];
const authId = await askInt('google_auth id');
if (authId == null) return;
return ['result[]', await client.company.list(Number(authId))];
}
case 'company.delete': {
const companyId = await askInt('Company id');