mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: wip attach attachments to resource models
This commit is contained in:
@@ -174,6 +174,7 @@ export default class CreditNote extends mixin(TenantModel, [
|
||||
const ItemEntry = require('models/ItemEntry');
|
||||
const Customer = require('models/Customer');
|
||||
const Branch = require('models/Branch');
|
||||
const Document = require('models/Document');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -233,6 +234,25 @@ export default class CreditNote extends mixin(TenantModel, [
|
||||
to: 'branches.id',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Credit note may has many attached attachments.
|
||||
*/
|
||||
attachments: {
|
||||
relation: Model.ManyToManyRelation,
|
||||
modelClass: Document.default,
|
||||
join: {
|
||||
from: 'credit_notes.id',
|
||||
through: {
|
||||
from: 'document_links.modelId',
|
||||
to: 'document_links.documentId',
|
||||
},
|
||||
to: 'documents.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_ref', 'CreditNote');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user