mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
add server to monorepo.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
import AccountsData from '../data/accounts';
|
||||
|
||||
export default class SeedAccounts extends TenantSeeder {
|
||||
/**
|
||||
* Seeds initial accounts to the organization.
|
||||
*/
|
||||
up(knex) {
|
||||
const data = AccountsData.map((account) => {
|
||||
return {
|
||||
...account,
|
||||
name: this.i18n.__(account.name),
|
||||
description: this.i18n.__(account.description),
|
||||
currencyCode: this.tenant.metadata.baseCurrency,
|
||||
};
|
||||
});
|
||||
return knex('accounts').then(async () => {
|
||||
// Inserts seed entries.
|
||||
return knex('accounts').insert(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
|
||||
export default class SeedSettings extends TenantSeeder {
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
up() {
|
||||
const settings = [
|
||||
// Orgnization settings.
|
||||
{ group: 'organization', key: 'accounting_basis', value: 'accural' },
|
||||
|
||||
// Accounts settings.
|
||||
{ group: 'accounts', key: 'account_code_unique', value: true },
|
||||
|
||||
// Manual journals settings.
|
||||
{ group: 'manual_journals', key: 'next_number', value: '00001' },
|
||||
{ group: 'manual_journals', key: 'auto_increment', value: true },
|
||||
|
||||
// Sale invoices settings.
|
||||
{ group: 'sales_invoices', key: 'next_number', value: '00001' },
|
||||
{ group: 'sales_invoices', key: 'number_prefix', value: 'INV-' },
|
||||
{ group: 'sales_invoices', key: 'auto_increment', value: true },
|
||||
|
||||
// Sale receipts settings.
|
||||
{ group: 'sales_receipts', key: 'next_number', value: '00001' },
|
||||
{ group: 'sales_receipts', key: 'number_prefix', value: 'REC-' },
|
||||
{ group: 'sales_receipts', key: 'auto_increment', value: true },
|
||||
|
||||
// Sale estimates settings.
|
||||
{ group: 'sales_estimates', key: 'next_number', value: '00001' },
|
||||
{ group: 'sales_estimates', key: 'number_prefix', value: 'EST-' },
|
||||
{ group: 'sales_estimates', key: 'auto_increment', value: true },
|
||||
|
||||
// Payment receives settings.
|
||||
{ group: 'payment_receives', key: 'number_prefix', value: 'PAY-' },
|
||||
{ group: 'payment_receives', key: 'next_number', value: '00001' },
|
||||
{ group: 'payment_receives', key: 'auto_increment', value: true },
|
||||
|
||||
// Cashflow settings.
|
||||
{ group: 'cashflow', key: 'number_prefix', value: 'CF-' },
|
||||
{ group: 'cashflow', key: 'next_number', value: '00001' },
|
||||
{ group: 'cashflow', key: 'auto_increment', value: true },
|
||||
|
||||
// warehouse transfers settings.
|
||||
{ group: 'warehouse_transfers', key: 'next_number', value: '00001' },
|
||||
{ group: 'warehouse_transfers', key: 'number_prefix', value: 'WT-' },
|
||||
{ group: 'warehouse_transfers', key: 'auto_increment', value: true },
|
||||
];
|
||||
return this.knex('settings').insert(settings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
|
||||
export default class SeedSettings extends TenantSeeder {
|
||||
/**
|
||||
*
|
||||
* @param knex
|
||||
* @returns
|
||||
*/
|
||||
async up(knex) {
|
||||
const costAccount = await knex('accounts')
|
||||
.where('slug', 'cost-of-goods-sold')
|
||||
.first();
|
||||
|
||||
const sellAccount = await knex('accounts')
|
||||
.where('slug', 'sales-of-product-income')
|
||||
.first();
|
||||
|
||||
const inventoryAccount = await knex('accounts')
|
||||
.where('slug', 'inventory-asset')
|
||||
.first();
|
||||
|
||||
const settings = [
|
||||
// Items settings.
|
||||
{ group: 'items', key: 'preferred_sell_account', value: sellAccount?.id },
|
||||
{ group: 'items', key: 'preferred_cost_account', value: costAccount?.id },
|
||||
{
|
||||
group: 'items',
|
||||
key: 'preferred_inventory_account',
|
||||
value: inventoryAccount?.id,
|
||||
},
|
||||
];
|
||||
return knex('settings').insert(settings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
|
||||
export default class SeedRolesAndPermissions extends TenantSeeder {
|
||||
/**
|
||||
* Seeds roles and associated permissiojns.
|
||||
* @param knex
|
||||
* @returns
|
||||
*/
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
async up(knex) {
|
||||
return knex('roles').insert([
|
||||
{
|
||||
id: 1,
|
||||
name: 'role.admin.name',
|
||||
predefined: true,
|
||||
slug: 'admin',
|
||||
description: 'role.admin.desc',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'role.staff.name',
|
||||
predefined: true,
|
||||
slug: 'staff',
|
||||
description: 'role.staff.desc',
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
|
||||
export default class SeedRolesAndPermissions extends TenantSeeder {
|
||||
/**
|
||||
* Seeds roles and associated permissiojns.
|
||||
* @param knex
|
||||
* @returns
|
||||
*/
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
async up(knex) {
|
||||
return knex('role_permissions').insert([
|
||||
// Assign sale invoice permissions to staff role.
|
||||
{ roleId: 2, subject: 'SaleInvoice', ability: 'create' },
|
||||
{ roleId: 2, subject: 'SaleInvoice', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'SaleInvoice', ability: 'view' },
|
||||
{ roleId: 2, subject: 'SaleInvoice', ability: 'edit' },
|
||||
|
||||
// Assign sale estimate permissions to staff role.
|
||||
{ roleId: 2, subject: 'SaleEstimate', ability: 'create' },
|
||||
{ roleId: 2, subject: 'SaleEstimate', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'SaleEstimate', ability: 'view' },
|
||||
{ roleId: 2, subject: 'SaleEstimate', ability: 'edit' },
|
||||
|
||||
// Assign sale receipt permissions to staff role.
|
||||
{ roleId: 2, subject: 'SaleReceipt', ability: 'create' },
|
||||
{ roleId: 2, subject: 'SaleReceipt', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'SaleReceipt', ability: 'view' },
|
||||
{ roleId: 2, subject: 'SaleReceipt', ability: 'edit' },
|
||||
|
||||
// Assign payment receive permissions to staff role.
|
||||
{ roleId: 2, subject: 'PaymentReceive', ability: 'create' },
|
||||
{ roleId: 2, subject: 'PaymentReceive', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'PaymentReceive', ability: 'view' },
|
||||
{ roleId: 2, subject: 'PaymentReceive', ability: 'edit' },
|
||||
|
||||
// Assign bill permissions to staff role.
|
||||
{ roleId: 2, subject: 'Bill', ability: 'create' },
|
||||
{ roleId: 2, subject: 'Bill', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'Bill', ability: 'view' },
|
||||
{ roleId: 2, subject: 'Bill', ability: 'edit' },
|
||||
|
||||
// Assign payment made permissions to staff role.
|
||||
{ roleId: 2, subject: 'PaymentMade', ability: 'create' },
|
||||
{ roleId: 2, subject: 'PaymentMade', ability: 'delete' },
|
||||
{ roleId: 2, subject: 'PaymentMade', ability: 'view' },
|
||||
{ roleId: 2, subject: 'PaymentMade', ability: 'edit' },
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { TenantSeeder } from '@/lib/Seeder/TenantSeeder';
|
||||
|
||||
export default class SeedCustomerVendorCreditSettings extends TenantSeeder {
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
up() {
|
||||
const settings = [
|
||||
// Credit note.
|
||||
{ group: 'credit_note', key: 'number_prefix', value: 'CN-' },
|
||||
{ group: 'credit_note', key: 'next_number', value: '00001' },
|
||||
{ group: 'credit_note', key: 'auto_increment', value: true },
|
||||
|
||||
// Vendor credit.
|
||||
{ group: 'vendor_credit', key: 'number_prefix', value: 'VC-' },
|
||||
{ group: 'vendor_credit', key: 'next_number', value: '00001' },
|
||||
{ group: 'vendor_credit', key: 'auto_increment', value: true },
|
||||
];
|
||||
return this.knex('settings').insert(settings);
|
||||
}
|
||||
}
|
||||
1
packages/server/src/database/seeds/core/index.ts
Normal file
1
packages/server/src/database/seeds/core/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
// .gitkeep
|
||||
318
packages/server/src/database/seeds/data/accounts.js
Normal file
318
packages/server/src/database/seeds/data/accounts.js
Normal file
@@ -0,0 +1,318 @@
|
||||
|
||||
export default [
|
||||
{
|
||||
name:'Bank Account',
|
||||
slug: 'bank-account',
|
||||
account_type: 'bank',
|
||||
code: '10001',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Saving Bank Account',
|
||||
slug: 'saving-bank-account',
|
||||
account_type: 'bank',
|
||||
code: '10002',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Undeposited Funds',
|
||||
slug: 'undeposited-funds',
|
||||
account_type: 'cash',
|
||||
code: '10003',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Petty Cash',
|
||||
slug: 'petty-cash',
|
||||
account_type: 'cash',
|
||||
code: '10004',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Computer Equipment',
|
||||
slug: 'computer-equipment',
|
||||
code: '10005',
|
||||
account_type: 'fixed-asset',
|
||||
predefined: 0,
|
||||
parent_account_id: null,
|
||||
index: 1,
|
||||
active: 1,
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
name:'Office Equipment',
|
||||
slug: 'office-equipment',
|
||||
code: '10006',
|
||||
account_type: 'fixed-asset',
|
||||
predefined: 0,
|
||||
parent_account_id: null,
|
||||
index: 1,
|
||||
active: 1,
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
name:'Accounts Receivable (A/R)',
|
||||
slug: 'accounts-receivable',
|
||||
account_type: 'accounts-receivable',
|
||||
code: '10007',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Inventory Asset',
|
||||
slug: 'inventory-asset',
|
||||
code: '10008',
|
||||
account_type: 'inventory',
|
||||
predefined: 1,
|
||||
parent_account_id: null,
|
||||
index: 1,
|
||||
active: 1,
|
||||
description:'An account that holds valuation of products or goods that availiable for sale.',
|
||||
},
|
||||
|
||||
// Libilities
|
||||
{
|
||||
name:'Accounts Payable (A/P)',
|
||||
slug: 'accounts-payable',
|
||||
account_type: 'accounts-payable',
|
||||
parent_account_id: null,
|
||||
code: '20001',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Owner A Drawings',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'other-current-liability',
|
||||
parent_account_id: null,
|
||||
code: '20002',
|
||||
description:'Withdrawals by the owners.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Loan',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'other-current-liability',
|
||||
code: '20003',
|
||||
description:'Money that has been borrowed from a creditor.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Opening Balance Liabilities',
|
||||
slug: 'opening-balance-liabilities',
|
||||
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,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Revenue Received in Advance',
|
||||
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.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Sales Tax Payable',
|
||||
slug: 'owner-drawings',
|
||||
account_type: 'other-current-liability',
|
||||
code: '20006',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
|
||||
// Equity
|
||||
{
|
||||
name:'Retained Earnings',
|
||||
slug: 'retained-earnings',
|
||||
account_type: 'equity',
|
||||
code: '30001',
|
||||
description:'Retained earnings tracks net income from previous fiscal years.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Opening Balance Equity',
|
||||
slug: 'opening-balance-equity',
|
||||
account_type: 'equity',
|
||||
code: '30002',
|
||||
description:'When you enter opening balances to the accounts, the amounts enter in Opening balance equity. This ensures that you have a correct trial balance sheet for your company, without even specific the second credit or debit entry.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name: "Owner's Equity",
|
||||
slug: 'owner-equity',
|
||||
account_type: 'equity',
|
||||
code: '30003',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:`Drawings`,
|
||||
slug: 'drawings',
|
||||
account_type: 'equity',
|
||||
code: '30003',
|
||||
description:'Goods purchased with the intention of selling these to customers',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
|
||||
// Expenses
|
||||
{
|
||||
name:'Other Expenses',
|
||||
slug: 'other-expenses',
|
||||
account_type: 'other-expense',
|
||||
parent_account_id: null,
|
||||
code: '40001',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Cost of Goods Sold',
|
||||
slug: '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.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Office expenses',
|
||||
slug: 'office-expenses',
|
||||
account_type: 'expense',
|
||||
parent_account_id: null,
|
||||
code: '40003',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Rent',
|
||||
slug: 'rent',
|
||||
account_type: 'expense',
|
||||
parent_account_id: null,
|
||||
code: '40004',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Exchange Gain or Loss',
|
||||
slug: 'exchange-grain-loss',
|
||||
account_type: 'other-expense',
|
||||
parent_account_id: null,
|
||||
code: '40005',
|
||||
description:'Tracks the gain and losses of the exchange differences.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Bank Fees and Charges',
|
||||
slug: 'bank-fees-and-charges',
|
||||
account_type: 'expense',
|
||||
parent_account_id: null,
|
||||
code: '40006',
|
||||
description: 'Any bank fees levied is recorded into the bank fees and charges account. A bank account maintenance fee, transaction charges, a late payment fee are some examples.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
{
|
||||
name:'Depreciation Expense',
|
||||
slug: 'depreciation-expense',
|
||||
account_type: 'expense',
|
||||
parent_account_id: null,
|
||||
code: '40007',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
},
|
||||
|
||||
// Income
|
||||
{
|
||||
name:'Sales of Product Income',
|
||||
slug: 'sales-of-product-income',
|
||||
account_type: 'income',
|
||||
predefined: 1,
|
||||
parent_account_id: null,
|
||||
code: '50001',
|
||||
index: 1,
|
||||
active: 1,
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
name:'Sales of Service Income',
|
||||
slug: 'sales-of-service-income',
|
||||
account_type: 'income',
|
||||
predefined: 0,
|
||||
parent_account_id: null,
|
||||
code: '50002',
|
||||
index: 1,
|
||||
active: 1,
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
name:'Uncategorized Income',
|
||||
slug: 'uncategorized-income',
|
||||
account_type: 'income',
|
||||
parent_account_id: null,
|
||||
code: '50003',
|
||||
description: '',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 1,
|
||||
},
|
||||
{
|
||||
name:'Other Income',
|
||||
slug: 'other-income',
|
||||
account_type: 'other-income',
|
||||
parent_account_id: null,
|
||||
code: '50004',
|
||||
description:'The income activities are not associated to the core business.',
|
||||
active: 1,
|
||||
index: 1,
|
||||
predefined: 0,
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user