mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
WIP Financial accounting module.
This commit is contained in:
10
server/src/models/ManualJournal.js
Normal file
10
server/src/models/ManualJournal.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import BaseModel from '@/models/Model';
|
||||
|
||||
export default class ManualJournal extends BaseModel {
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'manual_journals';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
39
server/src/models/ResourceFieldMetadata.js
Normal file
39
server/src/models/ResourceFieldMetadata.js
Normal 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',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user