Skip to content

Commit

Permalink
Implement possible fix
Browse files Browse the repository at this point in the history
Though have confirmed manually locally via a number of scenarios this does the trick.
  • Loading branch information
Cruikshanks committed Apr 18, 2023
1 parent caaa896 commit 821c4f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ async function _fetch (regionId, billingPeriod) {
'scheme',
'chargeVersions.startDate',
'chargeVersions.endDate',
'invoiceAccountId'
'invoiceAccountId',
'status'
])
.innerJoinRelated('licence')
.where('scheme', 'sroc')
.where('includeInSrocSupplementaryBilling', true)
.where('regionId', regionId)
.where('chargeVersions.status', 'current')
// .where('chargeVersions.status', 'current')
.where('chargeVersions.startDate', '>=', billingPeriod.startDate)
.where('chargeVersions.startDate', '<=', billingPeriod.endDate)
.whereNotExists(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ async function go (billingBatch, billingPeriod) {
currentBillingData.billingInvoice = billingInvoice
currentBillingData.billingInvoiceLicence = billingInvoiceLicence

const calculatedTransactions = _generateCalculatedTransactions(billingPeriod, chargeVersion, billingBatchId, billingInvoiceLicence)
currentBillingData.calculatedTransactions.push(...calculatedTransactions)
if (chargeVersion.status === 'current') {
const calculatedTransactions = _generateCalculatedTransactions(billingPeriod, chargeVersion, billingBatchId, billingInvoiceLicence)
currentBillingData.calculatedTransactions.push(...calculatedTransactions)
}
}
await _finaliseCurrentInvoiceLicence(currentBillingData, billingPeriod, billingBatch)

await _processReplacedChargeVersions(currentBillingData, billingBatch, billingPeriod)
// await _processReplacedChargeVersions(currentBillingData, billingBatch, billingPeriod)

await _finaliseBillingBatch(billingBatch, chargeVersions, currentBillingData.isEmpty)

Expand Down

0 comments on commit 821c4f6

Please sign in to comment.