WIP: transactions by customers.

This commit is contained in:
a.bouhuolia
2021-05-07 23:49:38 +02:00
parent 5f2e90b234
commit b5ed7af7eb
16 changed files with 425 additions and 76 deletions

View File

@@ -120,6 +120,25 @@ export default class AccountTransaction extends TenantModel {
query.modify('filterDateRange', null, toDate)
query.modify('sumationCreditDebit')
},
contactsOpeningBalance(query, openingDate, receivableAccounts, customersIds) {
// Filter by date.
query.modify('filterDateRange', null, openingDate);
// Filter by customers.
query.whereNot('contactId', null);
query.where('accountId', receivableAccounts);
if (customersIds) {
query.whereIn('contactId', customersIds);
}
// Group by the contact transactions.
query.groupBy('contactId');
query.sum('credit as credit');
query.sum('debit as debit');
query.select('contactId');
}
};
}