feat: retrieve all due invoices and bills or for specific customer/vendor.

This commit is contained in:
Ahmed Bouhuolia
2020-10-28 13:47:35 +02:00
parent 571716e82b
commit bc9638c9a2
6 changed files with 117 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
import { Model } from 'objection';
import { Model, raw } from 'objection';
import { difference } from 'lodash';
import TenantModel from 'models/TenantModel';
@@ -21,6 +21,14 @@ export default class Bill extends TenantModel {
return true;
}
static get modifiers() {
return {
dueBills(query) {
query.where(raw('AMOUNT - PAYMENT_AMOUNT > 0'));
}
}
}
/**
* Timestamps columns.
*/