mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: AR/AP aging summary report.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import { Bill } from 'models';
|
||||
import TenantRepository from 'repositories/TenantRepository';
|
||||
|
||||
@@ -8,4 +9,30 @@ export default class BillRepository extends TenantRepository {
|
||||
get model() {
|
||||
return Bill.bindKnex(this.knex);
|
||||
}
|
||||
|
||||
dueBills(asDate = moment().format('YYYY-MM-DD'), withRelations) {
|
||||
const cacheKey = this.getCacheKey('dueInvoices', asDate, withRelations);
|
||||
|
||||
return this.cache.get(cacheKey, () => {
|
||||
return this.model
|
||||
.query()
|
||||
.modify('dueBills')
|
||||
.modify('notOverdue')
|
||||
.modify('fromDate', asDate)
|
||||
.withGraphFetched(withRelations);
|
||||
});
|
||||
}
|
||||
|
||||
overdueBills(asDate = moment().format('YYYY-MM-DD'), withRelations) {
|
||||
const cacheKey = this.getCacheKey('overdueInvoices', asDate, withRelations);
|
||||
|
||||
return this.cache.get(cacheKey, () => {
|
||||
return this.model
|
||||
.query()
|
||||
.modify('dueBills')
|
||||
.modify('overdue', asDate)
|
||||
.modify('fromDate', asDate)
|
||||
.withGraphFetched(withRelations);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import { SaleInvoice } from 'models';
|
||||
import TenantRepository from 'repositories/TenantRepository';
|
||||
|
||||
@@ -8,4 +9,30 @@ export default class SaleInvoiceRepository extends TenantRepository {
|
||||
get model() {
|
||||
return SaleInvoice.bindKnex(this.knex);
|
||||
}
|
||||
}
|
||||
|
||||
dueInvoices(asDate = moment().format('YYYY-MM-DD'), withRelations) {
|
||||
const cacheKey = this.getCacheKey('dueInvoices', asDate, withRelations);
|
||||
|
||||
return this.cache.get(cacheKey, async () => {
|
||||
return this.model
|
||||
.query()
|
||||
.modify('dueInvoices')
|
||||
.modify('notOverdue', asDate)
|
||||
.modify('fromDate', asDate)
|
||||
.withGraphFetched(withRelations);
|
||||
});
|
||||
}
|
||||
|
||||
overdueInvoices(asDate = moment().format('YYYY-MM-DD'), withRelations) {
|
||||
const cacheKey = this.getCacheKey('overdueInvoices', asDate, withRelations);
|
||||
|
||||
return this.cache.get(cacheKey, () => {
|
||||
return this.model
|
||||
.query()
|
||||
.modify('dueInvoices')
|
||||
.modify('overdue', asDate)
|
||||
.modify('fromDate', asDate)
|
||||
.withGraphFetched(withRelations);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user