feat: remove path alias.

feat: remove Webpack and depend on nodemon.
feat: refactoring expenses.
feat: optimize system users with caching.
feat: architecture tenant optimize.
This commit is contained in:
Ahmed Bouhuolia
2020-09-15 00:51:39 +02:00
parent ad00f140d1
commit a22c8395f3
293 changed files with 3391 additions and 1637 deletions

View File

@@ -1,6 +1,6 @@
import KnexFactory from '@/lib/KnexFactory';
import KnexFactory from 'lib/KnexFactory';
import faker from 'faker';
import { hashPassword } from '@/utils';
import { hashPassword } from 'utils';
export default (tenantDb) => {

View File

@@ -1,5 +1,5 @@
import KnexFactory from '@/lib/KnexFactory';
import systemDb from '@/database/knex';
import KnexFactory from 'lib/KnexFactory';
import systemDb from 'database/knex';
import faker from 'faker';
export default () => {

View File

@@ -1,12 +0,0 @@
import Knex from 'knex';
import { knexSnakeCaseMappers } from 'objection';
import knexfile from '@/../config/systemKnexfile';
const config = knexfile[process.env.NODE_ENV];
export default () => {
return Knex({
...config,
...knexSnakeCaseMappers({ upperCase: true }),
});
};

View File

@@ -1,14 +0,0 @@
import knexManager from 'knex-db-manager';
import knexfile from '@/../config/systemKnexfile';
import config from '@/../config/config';
const knexConfig = knexfile[process.env.NODE_ENV];
export default () => knexManager.databaseManagerFactory({
knex: knexConfig,
dbManager: {
collate: [],
superUser: config.manager.superUser,
superPassword: config.manager.superPassword,
},
});

View File

@@ -3,10 +3,6 @@ exports.up = function (knex) {
return knex.schema.createTable('resources', (table) => {
table.increments();
table.string('name');
}).then(() => {
return knex.seed.run({
specific: 'seed_resources.js',
});
});
};

View File

@@ -14,11 +14,7 @@ exports.up = function (knex) {
table.decimal('amount', 15, 5);
table.string('currency_code', 3);
table.timestamps();
}).raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000').then(() => {
return knex.seed.run({
specific: 'seed_accounts.js',
});
});
}).raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000');
};
exports.down = (knex) => knex.schema.dropTableIfExists('accounts');

View File

@@ -9,11 +9,7 @@ exports.up = (knex) => {
table.string('child_type');
table.boolean('balance_sheet');
table.boolean('income_sheet');
}).raw('ALTER TABLE `ACCOUNT_TYPES` AUTO_INCREMENT = 1000').then(() => {
return knex.seed.run({
specific: 'seed_account_types.js',
});
});
}).raw('ALTER TABLE `ACCOUNT_TYPES` AUTO_INCREMENT = 1000');
};
exports.down = (knex) => knex.schema.dropTableIfExists('account_types');

View File

@@ -15,11 +15,7 @@ exports.up = function (knex) {
table.string('data_resource');
table.json('options');
table.integer('resource_id').unsigned();
}).raw('ALTER TABLE `RESOURCE_FIELDS` AUTO_INCREMENT = 1000').then(() => {
return knex.seed.run({
specific: 'seed_resources_fields.js',
});
});
}).raw('ALTER TABLE `RESOURCE_FIELDS` AUTO_INCREMENT = 1000');
};
exports.down = (knex) => knex.schema.dropTableIfExists('resource_fields');

View File

@@ -5,9 +5,7 @@ exports.up = function (knex) {
table.integer('view_id').unsigned();
table.integer('field_id').unsigned();
table.integer('index').unsigned();
}).raw('ALTER TABLE `ITEMS_CATEGORIES` AUTO_INCREMENT = 1000').then(() => {
});
}).raw('ALTER TABLE `ITEMS_CATEGORIES` AUTO_INCREMENT = 1000');
};
exports.down = (knex) => knex.schema.dropTableIfExists('view_has_columns');

View File

@@ -8,11 +8,7 @@ exports.up = function (knex) {
table.boolean('favourite');
table.string('roles_logic_expression');
table.timestamps();
}).raw('ALTER TABLE `VIEWS` AUTO_INCREMENT = 1000').then(() => {
return knex.seed.run({
specific: 'seed_views.js',
});
});
}).raw('ALTER TABLE `VIEWS` AUTO_INCREMENT = 1000');
};
exports.down = (knex) => knex.schema.dropTableIfExists('views');

View File

@@ -1,49 +0,0 @@
exports.up = function(knex) {
return knex.schema.createTable('contacts', table => {
table.increments();
table.string('contact_service');
table.string('contact_type');
table.decimal('balance', 13, 3).defaultTo(0);
table.decimal('opening_balance', 13, 3).defaultTo(0);
table.string('first_name').nullable();
table.string('last_name').nullable();
table.string('company_name').nullable();
table.string('display_name');
table.string('email').nullable();
table.string('work_phone').nullable();
table.string('personal_phone').nullable();
table.string('billing_address_1').nullable();
table.string('billing_address_2').nullable();
table.string('billing_address_city').nullable();
table.string('billing_address_country').nullable();
table.string('billing_address_email').nullable();
table.string('billing_address_zipcode').nullable();
table.string('billing_address_phone').nullable();
table.string('billing_address_state').nullable(),
table.string('shipping_address_1').nullable();
table.string('shipping_address_2').nullable();
table.string('shipping_address_city').nullable();
table.string('shipping_address_country').nullable();
table.string('shipping_address_email').nullable();
table.string('shipping_address_zipcode').nullable();
table.string('shipping_address_phone').nullable();
table.string('shipping_address_state').nullable();
table.text('note');
table.boolean('active').defaultTo(true);
table.timestamps();
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('contacts');
};

View File

@@ -1,46 +0,0 @@
exports.up = function(knex) {
return knex.schema.createTable('customers', table => {
table.increments();
table.string('customer_type');
table.decimal('balance', 13, 3).defaultTo(0);
table.string('first_name').nullable();
table.string('last_name').nullable();
table.string('company_name').nullable();
table.string('display_name');
table.string('email').nullable();
table.string('work_phone').nullable();
table.string('personal_phone').nullable();
table.string('billing_address_1').nullable();
table.string('billing_address_2').nullable();
table.string('billing_address_city').nullable();
table.string('billing_address_country').nullable();
table.string('billing_address_email').nullable();
table.string('billing_address_zipcode').nullable();
table.string('billing_address_phone').nullable();
table.string('billing_address_state').nullable(),
table.string('shipping_address_1').nullable();
table.string('shipping_address_2').nullable();
table.string('shipping_address_city').nullable();
table.string('shipping_address_country').nullable();
table.string('shipping_address_email').nullable();
table.string('shipping_address_zipcode').nullable();
table.string('shipping_address_phone').nullable();
table.string('shipping_address_state').nullable();
table.text('note');
table.boolean('active').defaultTo(true);
table.timestamps();
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('customers');
};

View File

@@ -0,0 +1,182 @@
import TenancyService from 'services/Tenancy/TenancyService'
import Container from 'typedi';
exports.up = function (knex) {
const tenancyService = Container.get(TenancyService);
const i18n = tenancyService.i18n(knex.userParams.tenantId);
return knex('accounts').then(() => {
// Inserts seed entries
return knex('accounts').insert([
{
id: 1,
name: 'Petty Cash',
slug: 'petty-cash',
account_type_id: 2,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 2,
name: 'Bank',
slug: 'bank',
account_type_id: 2,
parent_account_id: null,
code: '2000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 3,
name: 'Other Income',
slug: 'other-income',
account_type_id: 7,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 4,
name: 'Interest Income',
slug: 'interest-income',
account_type_id: 7,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 5,
name: 'Opening Balance',
slug: 'opening-balance',
account_type_id: 5,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 6,
name: 'Depreciation Expense',
slug: 'depreciation-expense',
account_type_id: 6,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 7,
name: 'Interest Expense',
slug: 'interest-expense',
account_type_id: 6,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 8,
name: 'Payroll Expenses',
slug: 'payroll-expenses',
account_type_id: 6,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 9,
name: 'Other Expenses',
slug: 'other-expenses',
account_type_id: 6,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 10,
name: 'Accounts Receivable',
slug: 'accounts-receivable',
account_type_id: 8,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 11,
name: 'Accounts Payable',
slug: 'accounts-payable',
account_type_id: 9,
parent_account_id: null,
code: '1000',
description: '',
active: 1,
index: 1,
predefined: 1,
},
{
id: 12,
name: 'Cost of Goods Sold (COGS)',
slug: 'cost-of-goods-sold',
account_type_id: 12,
predefined: 1,
parent_account_id: null,
index: 1,
active: 1,
description: 1,
},
{
id: 13,
name: 'Inventory Asset',
slug: 'inventory-asset',
account_type_id: 14,
predefined: 1,
parent_account_id: null,
index: 1,
active: 1,
description: '',
},
{
id: 14,
name: 'Sales of Product Income',
slug: 'sales-of-product-income',
account_type_id: 7,
predefined: 1,
parent_account_id: null,
index: 1,
active: 1,
description: '',
}
]);
});
};
exports.down = function (knex) {
};

View File

@@ -0,0 +1,148 @@
exports.up = function (knex) {
return knex('account_types').insert([
{
id: 1,
name: 'Fixed Asset',
key: 'fixed_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'fixed_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 2,
name: 'Current Asset',
key: 'current_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'current_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 14,
name: 'Other Asset',
key: 'other_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'other_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 3,
name: 'Long Term Liability',
key: 'long_term_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'long_term_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 4,
name: 'Current Liability',
key: 'current_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'current_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 13,
name: 'Other Liability',
key: 'other_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'other_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 5,
name: 'Equity',
key: 'equity',
normal: 'credit',
root_type: 'equity',
child_type: 'equity',
balance_sheet: true,
income_sheet: false,
},
{
id: 6,
name: 'Expense',
key: 'expense',
normal: 'debit',
root_type: 'expense',
child_type: 'expense',
balance_sheet: false,
income_sheet: true,
},
{
id: 10,
name: 'Other Expense',
key: 'other_expense',
normal: 'debit',
root_type: 'expense',
balance_sheet: false,
income_sheet: true,
},
{
id: 7,
name: 'Income',
key: 'income',
normal: 'credit',
root_type: 'income',
child_type: 'income',
balance_sheet: false,
income_sheet: true,
},
{
id: 11,
name: 'Other Income',
key: 'other_income',
normal: 'credit',
root_type: 'income',
child_type: 'other_income',
balance_sheet: false,
income_sheet: true,
},
{
id: 12,
name: 'Cost of Goods Sold (COGS)',
key: 'cost_of_goods_sold',
normal: 'debit',
root_type: 'expenses',
child_type: 'expenses',
balance_sheet: true,
income_sheet: false,
},
{
id: 8,
name: 'Accounts Receivable (A/R)',
key: 'accounts_receivable',
normal: 'debit',
root_type: 'asset',
child_type: 'current_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 9,
name: 'Accounts Payable (A/P)',
key: 'accounts_payable',
normal: 'credit',
root_type: 'liability',
child_type: 'current_liability',
balance_sheet: true,
income_sheet: false,
},
]);
};
exports.down = function(knex) {
}

View File

@@ -1,149 +0,0 @@
exports.seed = (knex) => {
// Deletes ALL existing entries
return knex('account_types').del()
.then(() => {
// Inserts seed entries
return knex('account_types').insert([
{
id: 1,
name: 'Fixed Asset',
key: 'fixed_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'fixed_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 2,
name: 'Current Asset',
key: 'current_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'current_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 14,
name: 'Other Asset',
key: 'other_asset',
normal: 'debit',
root_type: 'asset',
child_type: 'other_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 3,
name: 'Long Term Liability',
key: 'long_term_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'long_term_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 4,
name: 'Current Liability',
key: 'current_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'current_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 13,
name: 'Other Liability',
key: 'other_liability',
normal: 'credit',
root_type: 'liability',
child_type: 'other_liability',
balance_sheet: false,
income_sheet: true,
},
{
id: 5,
name: 'Equity',
key: 'equity',
normal: 'credit',
root_type: 'equity',
child_type: 'equity',
balance_sheet: true,
income_sheet: false,
},
{
id: 6,
name: 'Expense',
key: 'expense',
normal: 'debit',
root_type: 'expense',
child_type: 'expense',
balance_sheet: false,
income_sheet: true,
},
{
id: 10,
name: 'Other Expense',
key: 'other_expense',
normal: 'debit',
root_type: 'expense',
balance_sheet: false,
income_sheet: true,
},
{
id: 7,
name: 'Income',
key: 'income',
normal: 'credit',
root_type: 'income',
child_type: 'income',
balance_sheet: false,
income_sheet: true,
},
{
id: 11,
name: 'Other Income',
key: 'other_income',
normal: 'credit',
root_type: 'income',
child_type: 'other_income',
balance_sheet: false,
income_sheet: true,
},
{
id: 12,
name: 'Cost of Goods Sold (COGS)',
key: 'cost_of_goods_sold',
normal: 'debit',
root_type: 'expenses',
child_type: 'expenses',
balance_sheet: true,
income_sheet: false,
},
{
id: 8,
name: 'Accounts Receivable (A/R)',
key: 'accounts_receivable',
normal: 'debit',
root_type: 'asset',
child_type: 'current_asset',
balance_sheet: true,
income_sheet: false,
},
{
id: 9,
name: 'Accounts Payable (A/P)',
key: 'accounts_payable',
normal: 'credit',
root_type: 'liability',
child_type: 'current_liability',
balance_sheet: true,
income_sheet: false,
},
]);
});
};

View File

@@ -1,5 +1,7 @@
exports.seed = (knex) => {
console.log(knex.tenantId);
// Deletes ALL existing entries
return knex('accounts').del()
.then(() => {