refactoring: balance sheet report.

refactoring: trial balance sheet report.
refactoring: general ledger report.
refactoring: journal report.
refactoring: P&L report.
This commit is contained in:
Ahmed Bouhuolia
2020-12-10 13:04:49 +02:00
parent e8f329e29e
commit d49992a6d7
71 changed files with 3203 additions and 1571 deletions

View File

@@ -28,7 +28,7 @@ export default class AccountTransaction extends TenantModel {
* @param {number[]} accountsIds
*/
filterAccounts(query, accountsIds) {
if (accountsIds.length > 0) {
if (Array.isArray(accountsIds) && accountsIds.length > 0) {
query.whereIn('account_id', accountsIds);
}
},
@@ -63,9 +63,11 @@ export default class AccountTransaction extends TenantModel {
q.where('credit', '<=', toAmount);
q.orWhere('debit', '<=', toAmount);
});
}
}
},
sumationCreditDebit(query) {
query.select(['accountId']);
query.sum('credit as credit');
query.sum('debit as debit');
query.groupBy('account_id');
@@ -76,6 +78,16 @@ export default class AccountTransaction extends TenantModel {
filterContactIds(query, contactIds) {
query.whereIn('contact_id', contactIds);
},
openingBalance(query, fromDate) {
query.modify('filterDateRange', null, fromDate)
query.modify('sumationCreditDebit')
},
closingBalance(query, toDate) {
query.modify('filterDateRange', null, toDate)
query.modify('sumationCreditDebit')
},
};
}