u
This commit is contained in:
@@ -70,14 +70,10 @@ const MENU = {
|
||||
company: {
|
||||
label: 'company',
|
||||
items: [
|
||||
{ value: 'company.create', label: 'create', hint: 'iso639,name,taxrate,reducedtaxrate → id' },
|
||||
{ value: 'company.update', label: 'update', hint: 'id + same fields' },
|
||||
{ value: 'company.list', label: 'list', hint: '→ rows' },
|
||||
{ value: 'company.getById', label: 'getById', hint: 'id → row' },
|
||||
{ value: 'company.setDefaultLang', label: 'setDefaultLang', hint: 'companyId, langId' },
|
||||
{ value: 'company.setRootCategory', label: 'setRootCategory', hint: 'companyId, categoryId' },
|
||||
{ value: 'company.create', label: 'create', hint: 'iso639,name,taxes → result' },
|
||||
{ value: 'company.update', label: 'update', hint: 'id + fields → result' },
|
||||
{ value: 'company.list', label: 'list', hint: '→ result[]' },
|
||||
{ value: 'company.delete', label: 'delete', hint: 'companyId' },
|
||||
{ value: 'company.getByCompanyUserId', label: 'getByCompanyUserId', hint: 'id → tuple' },
|
||||
],
|
||||
},
|
||||
lang: {
|
||||
@@ -183,12 +179,13 @@ async function runMethod(client, action) {
|
||||
const reducedtaxrate = await askNumber('Reduced tax rate', '7');
|
||||
if (reducedtaxrate == null) return;
|
||||
|
||||
const companyId = await client.company.create({
|
||||
const created = await client.company.create({
|
||||
iso639,
|
||||
name,
|
||||
taxrate,
|
||||
reducedtaxrate,
|
||||
});
|
||||
const companyId = created.id;
|
||||
|
||||
const auths = await client.google_auth.list();
|
||||
const existingAuth = auths.find((row) => row.email === email);
|
||||
@@ -202,7 +199,7 @@ async function runMethod(client, action) {
|
||||
return [
|
||||
'created',
|
||||
{
|
||||
companyId,
|
||||
...created,
|
||||
companyUserId,
|
||||
authId,
|
||||
email,
|
||||
@@ -230,7 +227,7 @@ async function runMethod(client, action) {
|
||||
const reducedtaxrate = await askNumber('reducedtaxrate', '7');
|
||||
if (reducedtaxrate == null) return;
|
||||
return [
|
||||
'id',
|
||||
'result',
|
||||
await client.company.create({ iso639, name, taxrate, reducedtaxrate }),
|
||||
];
|
||||
}
|
||||
@@ -251,37 +248,18 @@ async function runMethod(client, action) {
|
||||
if (taxrate == null) return;
|
||||
const reducedtaxrate = await askNumber('reducedtaxrate', '7');
|
||||
if (reducedtaxrate == null) return;
|
||||
await client.company.update(Number(id), {
|
||||
iso639,
|
||||
name,
|
||||
taxrate,
|
||||
reducedtaxrate,
|
||||
});
|
||||
return ['ok', true];
|
||||
return [
|
||||
'result',
|
||||
await client.company.update(Number(id), {
|
||||
iso639,
|
||||
name,
|
||||
taxrate,
|
||||
reducedtaxrate,
|
||||
}),
|
||||
];
|
||||
}
|
||||
case 'company.list': {
|
||||
return ['rows', await client.company.list()];
|
||||
}
|
||||
case 'company.getById': {
|
||||
const id = await askInt('Company id');
|
||||
if (id == null) return;
|
||||
return ['row', await client.company.getById(Number(id))];
|
||||
}
|
||||
case 'company.setDefaultLang': {
|
||||
const companyId = await askInt('Company id');
|
||||
if (companyId == null) return;
|
||||
const languageId = await askInt('Language id');
|
||||
if (languageId == null) return;
|
||||
await client.company.setDefaultLang(Number(companyId), Number(languageId));
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'company.setRootCategory': {
|
||||
const companyId = await askInt('Company id');
|
||||
if (companyId == null) return;
|
||||
const categoryId = await askInt('Category id');
|
||||
if (categoryId == null) return;
|
||||
await client.company.setRootCategory(Number(companyId), Number(categoryId));
|
||||
return ['ok', true];
|
||||
return ['result[]', await client.company.list()];
|
||||
}
|
||||
case 'company.delete': {
|
||||
const companyId = await askInt('Company id');
|
||||
@@ -289,14 +267,6 @@ async function runMethod(client, action) {
|
||||
await client.company.delete(Number(companyId));
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'company.getByCompanyUserId': {
|
||||
const id = await askInt('Company user id');
|
||||
if (id == null) return;
|
||||
return [
|
||||
'[id, defaultLangId, rootCategoryId, name]',
|
||||
await client.company.getByCompanyUserId(Number(id)),
|
||||
];
|
||||
}
|
||||
case 'tax.create': {
|
||||
const rate = await askNumber('rate', '19');
|
||||
if (rate == null) return;
|
||||
|
||||
Reference in New Issue
Block a user