Skip to content

Commit

Permalink
Improve unpaid invoices report.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed May 23, 2022
1 parent a5ea035 commit 9d1d294
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.reporting = reporting;

async function build(req, res, next) {
const { dateTo } = req.query;
const { serviceUuid } = req.query;
const { enterprise } = req.session;
const currencyId = Number(req.query.currencyId);

Expand Down Expand Up @@ -45,6 +46,13 @@ async function build(req, res, next) {
results = { dataset : [], totals : {}, services : [] };
}

if (serviceUuid) {
// If the user selected a service, force it to be used as "uniqueService"
// even if no unpaid invoices for that service are found (to make the report clearer)
const [serviceInfo] = await db.exec('SELECT name FROM service WHERE uuid = ?', db.bid(serviceUuid));
qs.uniqueService = serviceInfo.name;
}

if (results.services.length === 1) {
[qs.uniqueService] = results.services;
// remove last column of total in the report rendered
Expand Down

0 comments on commit 9d1d294

Please sign in to comment.