Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FetchLicencesService #178

Merged
merged 3 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/presenters/check/supplementary-data.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@
*/

function go (data) {
const licences = data.licences.map((licence) => {
return {
licenceId: licence.licenceId,
licenceRef: licence.licenceRef,
licenceExistsInBilling: licence.numberOfTimesBilled > 0
}
})
const chargeVersions = data.chargeVersions

return {
billingPeriods: data.billingPeriods,
licences,
chargeVersions
}
}
Expand Down
5 changes: 1 addition & 4 deletions app/services/check/supplementary-data.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@

const BillingPeriodService = require('../supplementary-billing/billing-period.service.js')
const FetchChargeVersionsService = require('../supplementary-billing/fetch-charge-versions.service.js')
const FetchLicencesService = require('../supplementary-billing/fetch-licences.service.js')
const FetchRegionService = require('../supplementary-billing/fetch-region.service.js')
const SupplementaryDataPresenter = require('../../presenters/check/supplementary-data.presenter.js')

async function go (naldRegionId) {
const region = await FetchRegionService.go(naldRegionId)
const billingPeriods = BillingPeriodService.go()
const billingPeriodFinancialYearEnding = billingPeriods[0].endDate.getFullYear()
const licences = await FetchLicencesService.go(region, billingPeriodFinancialYearEnding)

// We know in the future we will be calculating multiple billing periods and so will have to iterate through each,
// generating bill runs and reviewing if there is anything to bill. For now, whilst our knowledge of the process
// is low we are focusing on just the current financial year, and intending to ship a working version for just it.
// This is why we are only passing through the first billing period; we know there is only one!
const chargeVersions = await FetchChargeVersionsService.go(region.regionId, billingPeriods[0])

return _response({ billingPeriods, licences, chargeVersions })
return _response({ billingPeriods, chargeVersions })
}

function _response (data) {
Expand Down
56 changes: 0 additions & 56 deletions app/services/supplementary-billing/fetch-licences.service.js

This file was deleted.

26 changes: 0 additions & 26 deletions test/presenters/check/supplementary-data.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ describe('Supplementary presenter', () => {
endDate: new Date(2023, 2, 31)
}
],
licences: [
{
licenceId: 'f1288f6c-8503-4dc1-b114-75c408a14bd0',
licenceRef: 'AT/SROC/SUPB/01',
numberOfTimesBilled: 1
},
{
licenceId: '81b50b35-459a-43f0-a48a-262028a34493',
licenceRef: 'AT/SROC/SUPB/02',
numberOfTimesBilled: 0
}
],
chargeVersions: [
{
chargeVersionId: '6a472535-145c-4170-ab59-f555783fa6e7',
Expand Down Expand Up @@ -72,18 +60,6 @@ describe('Supplementary presenter', () => {
expect(result.billingPeriods).to.have.length(1)
expect(result.billingPeriods[0]).to.equal(data.billingPeriods[0])

expect(result.licences).to.have.length(2)
expect(result.licences[0]).to.equal({
licenceId: data.licences[0].licenceId,
licenceRef: data.licences[0].licenceRef,
licenceExistsInBilling: true
})
expect(result.licences[1]).to.equal({
licenceId: data.licences[1].licenceId,
licenceRef: data.licences[1].licenceRef,
licenceExistsInBilling: false
})

expect(result.chargeVersions).to.have.length(1)
expect(result.chargeVersions[0]).to.equal(data.chargeVersions[0])
})
Expand All @@ -93,7 +69,6 @@ describe('Supplementary presenter', () => {
beforeEach(() => {
data = {
billingPeriods: [],
licences: [],
chargeVersions: []
}
})
Expand All @@ -102,7 +77,6 @@ describe('Supplementary presenter', () => {
const result = SupplementaryDataPresenter.go(data)

expect(result.billingPeriods).to.be.empty()
expect(result.licences).to.be.empty()
expect(result.chargeVersions).to.be.empty()
})
})
Expand Down
43 changes: 0 additions & 43 deletions test/services/check/supplementary-data.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { expect } = Code
// Things we need to stub
const BillingPeriodService = require('../../../app/services/supplementary-billing/billing-period.service.js')
const FetchChargeVersionsService = require('../../../app/services/supplementary-billing/fetch-charge-versions.service.js')
const FetchLicencesService = require('../../../app/services/supplementary-billing/fetch-licences.service.js')
const FetchRegionService = require('../../../app/services/supplementary-billing/fetch-region.service.js')

// Thing under test
Expand All @@ -35,7 +34,6 @@ describe('Supplementary service', () => {

describe('the response for billing periods', () => {
beforeEach(async () => {
Sinon.stub(FetchLicencesService, 'go').resolves([])
Sinon.stub(FetchChargeVersionsService, 'go').resolves([])
})

Expand All @@ -47,48 +45,7 @@ describe('Supplementary service', () => {
})
})

describe('the response for licences', () => {
beforeEach(async () => {
Sinon.stub(FetchChargeVersionsService, 'go').resolves([])
})

describe('when there are licences for supplementary billing', () => {
const testRecords = [{
licenceId: '4b5cbe04-a0e2-468c-909e-1e2d93810ba8',
licenceRef: 'AT/SROC/SUPB/01',
licenceExistsInBilling: true
}]

beforeEach(async () => {
Sinon.stub(FetchLicencesService, 'go').resolves(testRecords)
})

it('returns the matching licences', async () => {
const result = await SupplementaryDataService.go(naldRegionId)

expect(result.licences.length).to.equal(1)
expect(result.licences[0].licenceId).to.equal(testRecords[0].licenceId)
})
})

describe('When there are no licences for supplementary billing', () => {
beforeEach(async () => {
Sinon.stub(FetchLicencesService, 'go').resolves([])
})

it('returns no results', async () => {
const result = await SupplementaryDataService.go(naldRegionId)

expect(result.licences).to.be.empty()
})
})
})

describe('the response for charge versions', () => {
beforeEach(async () => {
Sinon.stub(FetchLicencesService, 'go').resolves([])
})

describe('when there are charge versions for supplementary billing', () => {
const testRecords = [{
chargeVersionId: '4b5cbe04-a0e2-468c-909e-1e2d93810ba8',
Expand Down
172 changes: 0 additions & 172 deletions test/services/supplementary-billing/fetch-licences.service.test.js

This file was deleted.