feat: wip attach attachments to resource models

This commit is contained in:
Ahmed Bouhuolia
2024-05-26 21:59:39 +02:00
parent 15dbc4137c
commit 2244cc6116
64 changed files with 2052 additions and 54 deletions

View File

@@ -182,6 +182,7 @@ export default class SaleEstimate extends mixin(TenantModel, [
const ItemEntry = require('models/ItemEntry');
const Customer = require('models/Customer');
const Branch = require('models/Branch');
const Document = require('models/Document');
return {
customer: {
@@ -219,6 +220,25 @@ export default class SaleEstimate extends mixin(TenantModel, [
to: 'branches.id',
},
},
/**
* Sale estimate transaction may has many attached attachments.
*/
attachments: {
relation: Model.ManyToManyRelation,
modelClass: Document.default,
join: {
from: 'sales_estimates.id',
through: {
from: 'document_links.modelId',
to: 'document_links.documentId',
},
to: 'documents.id',
},
filter(query) {
query.where('model_ref', 'Expense');
},
},
};
}