mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: Ability to hide/show financial statement header.
This commit is contained in:
22
server/src/database/seeds/seed_subscriptions_plans.js
Normal file
22
server/src/database/seeds/seed_subscriptions_plans.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
exports.seed = (knex) => {
|
||||
// Deletes ALL existing entries
|
||||
return knex('subscriptions_plans').del()
|
||||
.then(() => {
|
||||
// Inserts seed entries
|
||||
return knex('subscriptions_plans').insert([
|
||||
{
|
||||
id: 1,
|
||||
name: 'basic',
|
||||
price: 80,
|
||||
signup_fee: 0,
|
||||
currency: 'LYD',
|
||||
trial_period: 0,
|
||||
trial_interval: '',
|
||||
|
||||
invoice_period: 1,
|
||||
invoice_interval: 'month',
|
||||
}
|
||||
]);
|
||||
});
|
||||
};
|
||||
8
server/src/http/middleware/SubscriptionObserver.js
Normal file
8
server/src/http/middleware/SubscriptionObserver.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
const subscriptionObserver = (req, res, next) => {
|
||||
|
||||
};
|
||||
|
||||
export default subscriptionObserver;
|
||||
22
server/src/services/Subscription/UserSubscription.js
Normal file
22
server/src/services/Subscription/UserSubscription.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
export default (Model) => {
|
||||
return class UserSubscription extends Model{
|
||||
|
||||
onTrial() {
|
||||
|
||||
}
|
||||
|
||||
getSubscription() {
|
||||
|
||||
}
|
||||
|
||||
newSubscription() {
|
||||
|
||||
}
|
||||
|
||||
isSubcribedTo(plan) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('subscriptions_plans', table => {
|
||||
table.increments();
|
||||
|
||||
table.string('name');
|
||||
table.string('description');
|
||||
table.decimal('price');
|
||||
table.decimal('signup_fee');
|
||||
table.string('currency', 3);
|
||||
|
||||
table.integer('trial_period');
|
||||
table.string('trial_interval');
|
||||
|
||||
table.integer('invoice_period');
|
||||
table.string('invoice_interval');
|
||||
|
||||
table.timestamps();
|
||||
}).then(() => {
|
||||
return knex.seed.run({
|
||||
specific: 'seed_subscriptions_plans.js'
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('subscriptions_plans')
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('subscriptions_usage', table => {
|
||||
table.increments();
|
||||
table.integer('user_id');
|
||||
table.integer('plan_id');
|
||||
|
||||
table.dateTime('trial_ends_at');
|
||||
|
||||
table.dateTime('subscription_starts_at');
|
||||
table.dateTime('subscription_ends_at');
|
||||
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('subscriptions_usage');
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('subscription_licenses', table => {
|
||||
table.increments();
|
||||
table.string('key');
|
||||
table.integer('license_period');
|
||||
table.string('license_interval');
|
||||
table.boolean('used').defaultTo(false);
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('subscription_licenses');
|
||||
};
|
||||
18
server/src/system/models/SubscriptionLicense.js
Normal file
18
server/src/system/models/SubscriptionLicense.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
import SystemModel from '@/system/models/SystemModel';
|
||||
import DateSession from '@/models/DateSession';
|
||||
import UserSubscription from '@/services/Subscription/UserSubscription';
|
||||
|
||||
|
||||
export default class SubscriptionLicense extends mixin(SystemModel, [DateSession, UserSubscription]) {
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'subscription_licences';
|
||||
}
|
||||
|
||||
markAsUsed() {
|
||||
|
||||
}
|
||||
}
|
||||
10
server/src/system/models/SubscriptionPlan.js
Normal file
10
server/src/system/models/SubscriptionPlan.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import SystemModel from '@/system/models/SystemModel';
|
||||
|
||||
export default class SubscriptionPlan extends SystemModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'subscriptions_plans';
|
||||
}
|
||||
}
|
||||
10
server/src/system/models/SubscriptionUsage.js
Normal file
10
server/src/system/models/SubscriptionUsage.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import SystemModel from '@/system/models/SystemModel';
|
||||
|
||||
export default class SubscriptionUsage extends SystemModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'subscriptions_usage';
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,10 @@ import { Model, mixin } from 'objection';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import SystemModel from '@/system/models/SystemModel';
|
||||
import DateSession from '@/models/DateSession';
|
||||
import UserSubscription from '@/services/Subscription/UserSubscription';
|
||||
|
||||
|
||||
export default class SystemUser extends mixin(SystemModel, [DateSession]) {
|
||||
export default class SystemUser extends mixin(SystemModel, [DateSession, UserSubscription]) {
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
@@ -17,6 +18,7 @@ export default class SystemUser extends mixin(SystemModel, [DateSession]) {
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Tenant = require('@/system/models/Tenant');
|
||||
const SubscriptionUsage = require('@/system/models/SubscriptionUsage');
|
||||
|
||||
return {
|
||||
tenant: {
|
||||
@@ -27,6 +29,15 @@ export default class SystemUser extends mixin(SystemModel, [DateSession]) {
|
||||
to: 'tenants.id',
|
||||
},
|
||||
},
|
||||
|
||||
subscriptionUsage: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: SubscriptionUsage.default,
|
||||
join: {
|
||||
from: 'users.id',
|
||||
to: 'subscriptions_usage.user_id',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user