mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: redesign accounts types.
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
|
||||
exports.up = (knex) => {
|
||||
return knex.schema.createTable('account_types', (table) => {
|
||||
table.increments();
|
||||
table.string('key').index();
|
||||
table.string('normal').index();
|
||||
table.string('root_type').index();
|
||||
table.string('child_type');
|
||||
table.boolean('balance_sheet');
|
||||
table.boolean('income_sheet');
|
||||
}).raw('ALTER TABLE `ACCOUNT_TYPES` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('account_types');
|
||||
@@ -3,7 +3,7 @@ exports.up = function (knex) {
|
||||
table.increments('id').comment('Auto-generated id');
|
||||
table.string('name').index();
|
||||
table.string('slug');
|
||||
table.integer('account_type_id').unsigned().references('id').inTable('account_types');
|
||||
table.string('account_type').index();
|
||||
table.integer('parent_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.string('code', 10).index();
|
||||
table.text('description');
|
||||
|
||||
@@ -3,30 +3,10 @@ import { get } from 'lodash';
|
||||
import TenancyService from 'services/Tenancy/TenancyService'
|
||||
import AccountsData from '../data/accounts';
|
||||
|
||||
|
||||
exports.up = function (knex) {
|
||||
const tenancyService = Container.get(TenancyService);
|
||||
const i18n = tenancyService.i18n(knex.userParams.tenantId);
|
||||
|
||||
const accountMapper = (account) => {
|
||||
return knex('account_types').where('key', account.account_type).first()
|
||||
.then((accountType) => ({
|
||||
name: i18n.__(account.name),
|
||||
slug: account.slug,
|
||||
account_type_id: get(accountType, 'id', null),
|
||||
code: account.code,
|
||||
description: i18n.__(account.description),
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: account.predefined,
|
||||
}));
|
||||
};
|
||||
return knex('accounts').then(async () => {
|
||||
const accountsPromises = AccountsData.map(accountMapper);
|
||||
const accounts = await Promise.all(accountsPromises);
|
||||
|
||||
// Inserts seed entries.
|
||||
return knex('accounts').insert([ ...accounts ]);
|
||||
return knex('accounts').insert([ ...AccountsData ]);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export default [
|
||||
name:'Computer Equipment',
|
||||
slug: 'computer-equipment',
|
||||
code: '10005',
|
||||
account_type: 'fixed_asset',
|
||||
account_type: 'fixed-asset',
|
||||
predefined: 0,
|
||||
parent_account_id: null,
|
||||
index: 1,
|
||||
@@ -55,7 +55,7 @@ export default [
|
||||
name:'Office Equipment',
|
||||
slug: 'office-equipment',
|
||||
code: '10006',
|
||||
account_type: 'fixed_asset',
|
||||
account_type: 'fixed-asset',
|
||||
predefined: 0,
|
||||
parent_account_id: null,
|
||||
index: 1,
|
||||
@@ -65,7 +65,7 @@ export default [
|
||||
{
|
||||
name:'Accounts Receivable (A/R)',
|
||||
slug: 'accounts-receivable',
|
||||
account_type: 'accounts_receivable',
|
||||
account_type: 'accounts-receivable',
|
||||
code: '10007',
|
||||
description: '',
|
||||
active: 1,
|
||||
@@ -88,7 +88,7 @@ export default [
|
||||
{
|
||||
name:'Accounts Payable (A/P)',
|
||||
slug: 'accounts-payable',
|
||||
account_type: 'accounts_payable',
|
||||
account_type: 'accounts-payable',
|
||||
parent_account_id: null,
|
||||
code: '20001',
|
||||
description: '',
|
||||
@@ -99,7 +99,7 @@ export default [
|
||||
{
|
||||
name:'Owner A Drawings',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'other_current_liability',
|
||||
account_type: 'other-current-liability',
|
||||
parent_account_id: null,
|
||||
code: '20002',
|
||||
description:'Withdrawals by the owners.',
|
||||
@@ -110,7 +110,7 @@ export default [
|
||||
{
|
||||
name:'Loan',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'other_current_liability',
|
||||
account_type: 'other-current-liability',
|
||||
code: '20003',
|
||||
description:'Money that has been borrowed from a creditor.',
|
||||
active: 1,
|
||||
@@ -120,7 +120,7 @@ export default [
|
||||
{
|
||||
name:'Opening Balance Adjustments',
|
||||
slug: 'opening-balance-adjustments',
|
||||
account_type: 'other_current_liability',
|
||||
account_type: 'other-current-liability',
|
||||
code: '20004',
|
||||
description:'This account will hold the difference in the debits and credits entered during the opening balance..',
|
||||
active: 1,
|
||||
@@ -129,8 +129,8 @@ export default [
|
||||
},
|
||||
{
|
||||
name:'Revenue Received in Advance',
|
||||
slug: 'Revenue-received-in-advance',
|
||||
account_type: 'other_current_liability',
|
||||
slug: 'revenue-received-in-advance',
|
||||
account_type: 'other-current-liability',
|
||||
parent_account_id: null,
|
||||
code: '20005',
|
||||
description: 'When customers pay in advance for products/services.',
|
||||
@@ -141,7 +141,7 @@ export default [
|
||||
{
|
||||
name:'Sales Tax Payable',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'tax_payable',
|
||||
account_type: 'other-current-liability',
|
||||
code: '20006',
|
||||
description: '',
|
||||
active: 1,
|
||||
@@ -206,7 +206,7 @@ export default [
|
||||
{
|
||||
name:'Cost of Goods Sold',
|
||||
slug: 'cost-of-goods-sold',
|
||||
account_type: 'cost_of_goods_sold',
|
||||
account_type: 'cost-of-goods-sold',
|
||||
parent_account_id: null,
|
||||
code: '40002',
|
||||
description:'Tracks the direct cost of the goods sold.',
|
||||
@@ -239,7 +239,7 @@ export default [
|
||||
{
|
||||
name:'Exchange Gain or Loss',
|
||||
slug: 'exchange-grain-loss',
|
||||
account_type: 'other_expense',
|
||||
account_type: 'other-expense',
|
||||
parent_account_id: null,
|
||||
code: '40005',
|
||||
description:'Tracks the gain and losses of the exchange differences.',
|
||||
@@ -307,7 +307,7 @@ export default [
|
||||
{
|
||||
name:'Other Income',
|
||||
slug: 'other-income',
|
||||
account_type: 'other_income',
|
||||
account_type: 'other-income',
|
||||
parent_account_id: null,
|
||||
code: '50004',
|
||||
description:'The income activities are not associated to the core business.',
|
||||
|
||||
@@ -105,51 +105,5 @@ export default [
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
key: 'equity',
|
||||
normal: 'credit',
|
||||
root_type: 'equity',
|
||||
child_type: 'equity',
|
||||
balance_sheet: true,
|
||||
income_sheet: false,
|
||||
},
|
||||
{
|
||||
key: 'income',
|
||||
normal: 'credit',
|
||||
root_type: 'income',
|
||||
child_type: 'income',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
key: 'other_income',
|
||||
normal: 'credit',
|
||||
root_type: 'income',
|
||||
child_type: 'other_income',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
key: 'cost_of_goods_sold',
|
||||
normal: 'debit',
|
||||
root_type: 'expenses',
|
||||
child_type: 'expenses',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
key: 'expense',
|
||||
normal: 'debit',
|
||||
root_type: 'expense',
|
||||
child_type: 'expense',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
key: 'other_expense',
|
||||
normal: 'debit',
|
||||
root_type: 'expense',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user