From 1be03b049b41910c81cd3321e370c1bd2d12b6f0 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 20 Apr 2023 09:30:23 +0100 Subject: [PATCH] Make the WHERE clauses more explicit We have shied away from adding the table name to the licence fields in the WHERE clauses on the basis if it works don't fix it. But by adding `chargeVersions.` to all the charge version based ones we hope to make it clearer where the source of each comes from. --- .../supplementary-billing/fetch-charge-versions.service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/supplementary-billing/fetch-charge-versions.service.js b/app/services/supplementary-billing/fetch-charge-versions.service.js index 99fac7aad1..b936998bcd 100644 --- a/app/services/supplementary-billing/fetch-charge-versions.service.js +++ b/app/services/supplementary-billing/fetch-charge-versions.service.js @@ -36,10 +36,10 @@ async function _fetch (regionId, billingPeriod) { 'status' ]) .innerJoinRelated('licence') - .where('scheme', 'sroc') - .whereNotNull('invoiceAccountId') .where('includeInSrocSupplementaryBilling', true) .where('regionId', regionId) + .where('chargeVersions.scheme', 'sroc') + .whereNotNull('chargeVersions.invoiceAccountId') .where('chargeVersions.startDate', '>=', billingPeriod.startDate) .where('chargeVersions.startDate', '<=', billingPeriod.endDate) .whereNot('chargeVersions.status', 'draft')