feat: Ability to hide/show financial statement header.

This commit is contained in:
Ahmed Bouhuolia
2020-05-27 20:21:05 +02:00
parent 2e8ffa2aa9
commit c1659d191f
47 changed files with 914 additions and 301 deletions

57
server/bin/license.js Normal file
View File

@@ -0,0 +1,57 @@
const commander = require('commander');
const color = require('colorette');
const argv = require('getopts')(process.argv.slice(2));
const cryptoRandomString = require('crypto-random-string');
const {
initSystemKnex,
getAllSystemTenants,
initTenantKnex,
exit,
success,
log,
} = require('./utils');
// License generate key.
commander
.command('license:generate <license_period>')
.description('Generates a new license key.')
.action(async (interval) => {
try {
const sysDb = initSystemKnex();
let repeat = true;
while(repeat) {
key = cryptoRandomString(16).toUpperCase();
const license = await sysDb('subscription_licenses').where('key', key);
if (license.length === 0) {
repeat = false;
}
}
const licenseIds = await sysDb('subscription_licenses').insert({
key,
license_period: interval ? parseInt(interval, 10) : 1,
license_interval: 'month',
});
const license = await sysDb('subscription_licenses').where('id', licenseIds[0]).first();
success(`ID: ${license.id} | License: ${license.key} | Interval: ${license.licenseInterval} | Period: ${license.licensePeriod}`);
} catch(error) {
exit(error);
}
});
// Retrieve licenses list.
commander
.command('licenses:list')
.description('Retrieve a list of subscription licenses.')
.action(async () => {
const sysDb = initSystemKnex();
const licenses = await sysDb('subscription_licenses');
licenses.forEach((license) => {
log(`ID: ${license.id} | Key: ${license.key} | Interval: ${license.licenseInterval} | Period: ${license.licensePeriod}`);
});
exit();
});
commander.parse(process.argv);