mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: wip attach attachments to resource models
This commit is contained in:
@@ -177,6 +177,7 @@ export default class VendorCredit extends mixin(TenantModel, [
|
||||
const Vendor = require('models/Vendor');
|
||||
const ItemEntry = require('models/ItemEntry');
|
||||
const Branch = require('models/Branch');
|
||||
const Document = require('models/Document');
|
||||
|
||||
return {
|
||||
vendor: {
|
||||
@@ -215,6 +216,25 @@ export default class VendorCredit extends mixin(TenantModel, [
|
||||
to: 'branches.id',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Vendor credit may has many attached attachments.
|
||||
*/
|
||||
attachments: {
|
||||
relation: Model.ManyToManyRelation,
|
||||
modelClass: Document.default,
|
||||
join: {
|
||||
from: 'vendor_credits.id',
|
||||
through: {
|
||||
from: 'document_links.modelId',
|
||||
to: 'document_links.documentId',
|
||||
},
|
||||
to: 'documents.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_ref', 'VendorCredit');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user