fix: Filter financial reports by items, customers or vendors.

This commit is contained in:
a.bouhuolia
2021-07-25 03:59:02 +02:00
parent 504b380da6
commit 3a7f8a4512
71 changed files with 1021 additions and 350 deletions

View File

@@ -1,4 +1,4 @@
import { map } from 'lodash';
import { isEmpty, map } from 'lodash';
import { IAccount, IAccountTransaction } from 'interfaces';
import { ACCOUNT_TYPE } from 'data/AccountTypes';
import HasTenancyService from 'services/Tenancy/TenancyService';
@@ -13,10 +13,16 @@ export default class TransactionsByCustomersRepository {
* @param {number} tenantId
* @returns {Promise<ICustomer[]>}
*/
public async getCustomers(tenantId: number) {
public async getCustomers(tenantId: number, customersIds?: number[]) {
const { Customer } = this.tenancy.models(tenantId);
return Customer.query().orderBy('displayName');
return Customer.query().onBuild((q) => {
q.orderBy('displayName');
if (!isEmpty(customersIds)) {
q.whereIn('id', customersIds);
}
});
}
/**