mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: wip attach attachments to resource models
This commit is contained in:
@@ -108,6 +108,7 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
||||
const AccountTransaction = require('models/AccountTransaction');
|
||||
const ItemEntry = require('models/ItemEntry');
|
||||
const Branch = require('models/Branch');
|
||||
const Document = require('models/Document');
|
||||
|
||||
return {
|
||||
customer: {
|
||||
@@ -167,6 +168,25 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
||||
to: 'branches.id',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Sale receipt transaction may has many attached attachments.
|
||||
*/
|
||||
attachments: {
|
||||
relation: Model.ManyToManyRelation,
|
||||
modelClass: Document.default,
|
||||
join: {
|
||||
from: 'sales_receipts.id',
|
||||
through: {
|
||||
from: 'document_links.modelId',
|
||||
to: 'document_links.documentId',
|
||||
},
|
||||
to: 'documents.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_ref', 'SaleReceipt');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user