Skip to content

Commit

Permalink
Remove empty charge period guard clause
Browse files Browse the repository at this point in the history
With [Exclude ended licences in two-part tariff matching](#595) being merged we should always have a populated charge period so there is no need for the guard clause any more.
  • Loading branch information
Cruikshanks committed Dec 15, 2023
1 parent 2379dec commit e612e6b
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions app/services/check/stand-ins.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,11 @@ async function _prepareLicencesForAllocation (licences, billingPeriod) {
_sortChargeReferencesBySubsistenceCharge(chargeReferences)
chargeVersion.chargePeriod = DetermineChargePeriodService.go(chargeVersion, billingPeriod)

// NOTE: Imagine the scenario where a billing account change is due to happen. The users will create a new charge
// version whose start date will be when the account is due to change, for example 1 Oct. So, the charge version
// we are looking at has a `startDate:` of 2023-10-01. But then someone marks the licence as revoked in NALD on
// 2023-08-01. In this scenario DetermineChargePeriodService will return an empty charge period because it will
// have calculated the charge period start date as 2023-10-01 and the end date as 2023-08-01. Clearly, this is
// incompatible so the service actually returns `{ startDate: null, endDate: null }`. This check is to handle
// scenarios like this
if (chargeVersion.chargePeriod.startDate) {
chargeReferences.forEach((chargeReference) => {
const { chargeElements } = chargeReference

_prepChargeElementsForMatching(chargeElements, chargeVersion.chargePeriod)
})
}
chargeReferences.forEach((chargeReference) => {
const { chargeElements } = chargeReference

_prepChargeElementsForMatching(chargeElements, chargeVersion.chargePeriod)
})
})
}
}
Expand Down

0 comments on commit e612e6b

Please sign in to comment.