mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: Graph fetch relations with sales & purchases models.
feat: Inventory tracker algorithm lots with FIFO or LIFO cost method.
This commit is contained in:
@@ -23,8 +23,18 @@ export default class SaleEstimate extends mixin(TenantModel, [CachableModel]) {
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const ItemEntry = require('@/models/ItemEntry');
|
||||
const Customer = require('@/models/Customer');
|
||||
|
||||
return {
|
||||
customer: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: this.relationBindKnex(Customer.default),
|
||||
join: {
|
||||
from: 'sales_estimates.customerId',
|
||||
to: 'customers.id',
|
||||
},
|
||||
},
|
||||
|
||||
entries: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: this.relationBindKnex(ItemEntry.default),
|
||||
@@ -32,6 +42,9 @@ export default class SaleEstimate extends mixin(TenantModel, [CachableModel]) {
|
||||
from: 'sales_estimates.id',
|
||||
to: 'items_entries.referenceId',
|
||||
},
|
||||
filter(builder) {
|
||||
builder.where('reference_type', 'SaleEstimate');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user