fix issues in sales and purchases module.

This commit is contained in:
Ahmed Bouhuolia
2020-08-05 16:25:53 +02:00
parent ad772cf247
commit 57ec5bdfbe
12 changed files with 236 additions and 62 deletions

View File

@@ -38,8 +38,12 @@ export default class SaleInvoice extends mixin(TenantModel, [CachableModel]) {
*/
static get relationMappings() {
const ItemEntry = require('@/models/ItemEntry');
const Customer = require('@/models/Customer');
return {
/**
*
*/
entries: {
relation: Model.HasManyRelation,
modelClass: this.relationBindKnex(ItemEntry.default),
@@ -48,6 +52,18 @@ export default class SaleInvoice extends mixin(TenantModel, [CachableModel]) {
to: 'items_entries.referenceId',
},
},
/**
*
*/
customer: {
relation: Model.BelongsToOneRelation,
modelClass: this.relationBindKnex(Customer.default),
join: {
from: 'sales_invoices.customerId',
to: 'customers.id',
},
},
};
}
@@ -64,4 +80,6 @@ export default class SaleInvoice extends mixin(TenantModel, [CachableModel]) {
.where('id', invoiceId)
[changeMethod]('payment_amount', Math.abs(amount));
}
}