WIP Financial accounting module.

This commit is contained in:
Ahmed Bouhuolia
2020-01-25 23:34:08 +02:00
parent 488709088b
commit 77c67cc4cb
26 changed files with 1414 additions and 354 deletions

View File

@@ -0,0 +1,10 @@
import BaseModel from '@/models/Model';
export default class ManualJournal extends BaseModel {
/**
* Table name.
*/
static get tableName() {
return 'manual_journals';
}
}

View File

@@ -8,7 +8,10 @@ export default class ModelBase extends Model {
static query(...args) {
return super.query(...args).runAfter((result) => {
return this.collection.from(result);
if (Array.isArray(result)) {
return this.collection.from(result);
}
return result;
});
}
}

View File

@@ -11,6 +11,21 @@ export default class ResourceField extends BaseModel {
return 'resource_fields';
}
static get jsonAttributes() {
return ['options'];
}
/**
* Model modifiers.
*/
static get modifiers() {
return {
whereNotPredefined(query) {
query.whereNot('predefined', true);
},
};
}
/**
* Timestamp columns.
*/

View File

@@ -0,0 +1,39 @@
import { Model } from 'objection';
import path from 'path';
import BaseModel from '@/models/Model';
import MetableCollection from '@/lib/Metable/MetableCollection';
export default class ResourceFieldMetadata extends BaseModel {
/**
* Table name.
*/
static get tableName() {
return 'resource_custom_fields_metadata';
}
/**
* Override the resource field metadata collection.
*/
static get collection() {
return MetableCollection;
}
/**
* Relationship mapping.
*/
static get relationMappings() {
return {
/**
* Resource field may belongs to resource model.
*/
resource: {
relation: Model.BelongsToOneRelation,
modelBase: path.join(__dirname, 'Resource'),
join: {
from: 'resource_fields.resource_id',
to: 'resources.id',
},
},
};
}
}