WIP: Allocate landed cost.

This commit is contained in:
a.bouhuolia
2021-07-22 18:11:17 +02:00
parent 1eacc254d8
commit 76c6cb3699
33 changed files with 1577 additions and 163 deletions

View File

@@ -17,6 +17,7 @@ exports.up = function (knex) {
table.text('sell_description').nullable();
table.text('purchase_description').nullable();
table.integer('quantity_on_hand');
table.boolean('landed_cost').nullable();
table.text('note').nullable();
table.boolean('active');

View File

@@ -1,20 +1,29 @@
exports.up = function (knex) {
return knex.schema
.createTable('expenses_transactions', (table) => {
table.increments();
table.string('currency_code', 3);
table.text('description');
table
.integer('payment_account_id')
.unsigned()
.references('id')
.inTable('accounts');
table.integer('payee_id').unsigned().references('id').inTable('contacts');
table.string('reference_no');
exports.up = function(knex) {
return knex.schema.createTable('expenses_transactions', (table) => {
table.increments();
table.decimal('total_amount', 13, 3);
table.string('currency_code', 3);
table.text('description');
table.integer('payment_account_id').unsigned().references('id').inTable('accounts');
table.integer('payee_id').unsigned().references('id').inTable('contacts');;
table.string('reference_no');
table.date('published_at').index();
table.integer('user_id').unsigned().index();
table.date('payment_date').index();
table.timestamps();
}).raw('ALTER TABLE `EXPENSES_TRANSACTIONS` AUTO_INCREMENT = 1000');
table.decimal('total_amount', 13, 3);
table.decimal('landed_cost_amount', 13, 3).defaultTo(0);
table.decimal('allocated_cost_amount', 13, 3).defaultTo(0);
table.date('published_at').index();
table.integer('user_id').unsigned().index();
table.date('payment_date').index();
table.timestamps();
})
.raw('ALTER TABLE `EXPENSES_TRANSACTIONS` AUTO_INCREMENT = 1000');
};
exports.down = function(knex) {
exports.down = function (knex) {
return knex.schema.dropTableIfExists('expenses');
};

View File

@@ -1,16 +1,29 @@
exports.up = function(knex) {
return knex.schema.createTable('expense_transaction_categories', table => {
table.increments();
table.integer('expense_account_id').unsigned().index().references('id').inTable('accounts');
table.integer('index').unsigned();
table.text('description');
table.decimal('amount', 13, 3);
table.integer('expense_id').unsigned().index().references('id').inTable('expenses_transactions');
table.timestamps();
}).raw('ALTER TABLE `EXPENSE_TRANSACTION_CATEGORIES` AUTO_INCREMENT = 1000');;
exports.up = function (knex) {
return knex.schema
.createTable('expense_transaction_categories', (table) => {
table.increments();
table
.integer('expense_account_id')
.unsigned()
.index()
.references('id')
.inTable('accounts');
table.integer('index').unsigned();
table.text('description');
table.decimal('amount', 13, 3);
table.decimal('allocated_cost_amount', 13, 3).defaultTo(0);
table.boolean('landed_cost').defaultTo(false);
table
.integer('expense_id')
.unsigned()
.index()
.references('id')
.inTable('expenses_transactions');
table.timestamps();
})
.raw('ALTER TABLE `EXPENSE_TRANSACTION_CATEGORIES` AUTO_INCREMENT = 1000');
};
exports.down = function(knex) {
exports.down = function (knex) {
return knex.schema.dropTableIfExists('expense_transaction_categories');
};

View File

@@ -1,8 +1,12 @@
exports.up = function(knex) {
exports.up = function (knex) {
return knex.schema.createTable('bills', (table) => {
table.increments();
table.integer('vendor_id').unsigned().index().references('id').inTable('contacts');
table
.integer('vendor_id')
.unsigned()
.index()
.references('id')
.inTable('contacts');
table.string('bill_number');
table.date('bill_date').index();
table.date('due_date').index();
@@ -12,6 +16,8 @@ exports.up = function(knex) {
table.decimal('amount', 13, 3).defaultTo(0);
table.string('currency_code');
table.decimal('payment_amount', 13, 3).defaultTo(0);
table.decimal('landed_cost_amount', 13, 3).defaultTo(0);
table.decimal('allocated_cost_amount', 13, 3).defaultTo(0);
table.string('inv_lot_number').index();
table.date('opened_at').index();
table.integer('user_id').unsigned();
@@ -19,6 +25,6 @@ exports.up = function(knex) {
});
};
exports.down = function(knex) {
exports.down = function (knex) {
return knex.schema.dropTableIfExists('bills');
};

View File

@@ -0,0 +1,21 @@
exports.up = function (knex) {
return knex.schema.createTable('bill_located_costs', (table) => {
table.increments();
table.decimal('amount', 13, 3).unsigned();
table.integer('fromTransactionId').unsigned();
table.string('fromTransactionType');
table.integer('fromTransactionEntryId').unsigned();
table.string('allocationMethod');
table.integer('costAccountId').unsigned();
table.text('description');
table.integer('billId').unsigned();
table.timestamps();
});
};
exports.down = function (knex) {};

View File

@@ -0,0 +1,11 @@
exports.up = function (knex) {
return knex.schema.createTable('bill_located_cost_entries', (table) => {
table.increments();
table.decimal('cost', 13, 3).unsigned();
table.integer('entry_id').unsigned();
table.integer('bill_located_cost_id').unsigned();
});
};
exports.down = function (knex) {};

View File

@@ -15,6 +15,8 @@ exports.up = function(knex) {
table.integer('sell_account_id').unsigned().references('id').inTable('accounts');
table.integer('cost_account_id').unsigned().references('id').inTable('accounts');
table.boolean('landed_cost').defaultTo(false);
table.decimal('allocated_cost_amount', 13, 3);
table.timestamps();
});
};