mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: Expenses resource.
This commit is contained in:
@@ -97,6 +97,7 @@ export default (tenantDb) => {
|
||||
const costAccount = await factory.create('account');
|
||||
const sellAccount = await factory.create('account');
|
||||
const inventoryAccount = await factory.create('account');
|
||||
|
||||
return {
|
||||
name: faker.lorem.word(),
|
||||
note: faker.lorem.paragraph(),
|
||||
@@ -222,17 +223,30 @@ export default (tenantDb) => {
|
||||
};
|
||||
});
|
||||
|
||||
factory.define('expense', 'expenses', async () => {
|
||||
factory.define('expense', 'expenses_transactions', async () => {
|
||||
const paymentAccount = await factory.create('account');
|
||||
const expenseAccount = await factory.create('account');
|
||||
const user = await factory.create('user');
|
||||
|
||||
return {
|
||||
payment_account_id: paymentAccount.id,
|
||||
expense_account_id: expenseAccount.id,
|
||||
user_id: user.id,
|
||||
amount: faker.random.number(),
|
||||
total_amount: faker.random.number(),
|
||||
currency_code: 'USD',
|
||||
description: '',
|
||||
reference_no: faker.random.number(),
|
||||
payment_account_id: paymentAccount.id,
|
||||
published: true,
|
||||
user_id: user.id,
|
||||
};
|
||||
});
|
||||
|
||||
factory.define('expense_category', 'expense_transaction_categories', async () => {
|
||||
const expense = await factory.create('expense');
|
||||
|
||||
return {
|
||||
expense_account_id: expense.id,
|
||||
description: '',
|
||||
amount: faker.random.number(),
|
||||
expense_id: expense.id,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('expenses', (table) => {
|
||||
return knex.schema.createTable('expenses_transactions', (table) => {
|
||||
table.increments();
|
||||
table.decimal('amount');
|
||||
table.decimal('total_amount');
|
||||
table.string('currency_code');
|
||||
table.decimal('exchange_rate');
|
||||
table.text('description');
|
||||
table.integer('expense_account_id').unsigned();
|
||||
table.integer('payment_account_id').unsigned();
|
||||
table.string('reference');
|
||||
table.integer('payee_id').unsigned();
|
||||
table.string('reference_no');
|
||||
table.boolean('published').defaultTo(false);
|
||||
table.integer('user_id').unsigned();
|
||||
table.date('date');
|
||||
// table.timestamps();
|
||||
})
|
||||
table.date('payment_date');
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `EXPENSES_TRANSACTIONS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('expense_transaction_categories', table => {
|
||||
table.increments();
|
||||
table.integer('expense_account_id').unsigned();
|
||||
table.integer('index').unsigned();
|
||||
table.text('description');
|
||||
table.decimal('amount');
|
||||
table.integer('expense_id').unsigned();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `EXPENSE_TRANSACTION_CATEGORIES` AUTO_INCREMENT = 1000');;
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('expense_transaction_categories');
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
|
||||
};
|
||||
@@ -49,6 +49,15 @@ exports.seed = (knex) => {
|
||||
predefined: 1,
|
||||
columnable: true,
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
resource_id: 1,
|
||||
label_name: 'Created at',
|
||||
data_type: 'date',
|
||||
key: 'created_at',
|
||||
predefined: 1,
|
||||
columnable: true,
|
||||
},
|
||||
|
||||
// Expenses
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user