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

Rename bill presenters to match convention #538

Merged
merged 1 commit into from
Nov 22, 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
12 changes: 6 additions & 6 deletions app/presenters/bill-licences/view-bill-licence.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

const { formatMoney } = require('../base.presenter.js')
const CompensationChargeTransactionPresenter = require('./compensation-charge-transaction.presenter.js')
const MinimumChargeTransactionPresenter = require('./minimum-charge-transaction.presenter.js')
const StandardChargeTransactionPresenter = require('./standard-charge-transaction.presenter.js')
const ViewCompensationChargeTransactionPresenter = require('./view-compensation-charge-transaction.presenter.js')
const ViewMinimumChargeTransactionPresenter = require('./view-minimum-charge-transaction.presenter.js')
const ViewStandardChargeTransactionPresenter = require('./view-standard-charge-transaction.presenter.js')

/**
* Formats data for a bill licence including its transactions into what is needed for the bill-licence page
Expand Down Expand Up @@ -85,14 +85,14 @@ function _transactions (transactions) {
const { chargeType } = transaction

if (chargeType === 'minimum_charge') {
return MinimumChargeTransactionPresenter.go(transaction)
return ViewMinimumChargeTransactionPresenter.go(transaction)
}

if (chargeType === 'compensation') {
return CompensationChargeTransactionPresenter.go(transaction)
return ViewCompensationChargeTransactionPresenter.go(transaction)
}

return StandardChargeTransactionPresenter.go(transaction)
return ViewStandardChargeTransactionPresenter.go(transaction)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Formats data for a compensation charge transaction for the bill-licence page
* @module CompensationChargeTransactionPresenter
* @module ViewCompensationChargeTransactionPresenter
*/

const { formatLongDate, formatMoney } = require('../base.presenter.js')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Formats data for minimum charge transaction for the bill-licence page
* @module MinimumChargeTransactionPresenter
* @module ViewMinimumChargeTransactionPresenter
*/

const { formatMoney } = require('../base.presenter.js')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Formats data for a standard charge transaction for the bill-licence page
* @module StandardChargeTransactionPresenter
* @module ViewStandardChargeTransactionPresenter
*/

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Formats bill data ready for presenting in the single licence bill and multi licence bill pages
* @module BillPresenter
* @module ViewBillPresenter
*/

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Formats summary data of licences connected to a bill for the multi-licence bill page
* @module LicenceSummariesPresenter
* @module ViewLicenceSummariesPresenter
*/

const { formatMoney } = require('../base.presenter.js')
Expand Down
8 changes: 4 additions & 4 deletions app/services/bills/view-bill.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @module ViewBillService
*/

const BillPresenter = require('../../presenters/bills/bill.presenter.js')
const FetchBillingAccountService = require('./fetch-billing-account.service.js')
const FetchBillLicence = require('../bill-licences/fetch-bill-licence.service.js')
const FetchBillService = require('./fetch-bill-service.js')
const LicenceSummariesPresenter = require('../../presenters/bills/licence-summaries.presenter.js')
const ViewBillPresenter = require('../../presenters/bills/view-bill.presenter.js')
const ViewBillLicencePresenter = require('../../presenters/bill-licences/view-bill-licence.presenter.js')
const ViewLicenceSummariesPresenter = require('../../presenters/bills/view-licence-summaries.presenter.js')

/**
* Orchestrates fetching and presenting the data needed for one of the view bill templates
Expand All @@ -35,13 +35,13 @@ async function go (id) {

// Irrespective of of how many licences are linked to the bill, the templates always need formatted bill and billing
// account data
const billAndBillingAccountData = BillPresenter.go(bill, billingAccount)
const billAndBillingAccountData = ViewBillPresenter.go(bill, billingAccount)

let additionalData = {}

// If we have multiple licences we need to provide formatted licence summary data for the multi licence bill template
if (licenceSummaries.length > 1) {
additionalData = LicenceSummariesPresenter.go(licenceSummaries)
additionalData = ViewLicenceSummariesPresenter.go(licenceSummaries)
} else {
// Else we need to provide we need to provide bill licence data for the single licence bill templates
// (ViewBillLicencePresenter handles both PRESROC and SROC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script()
const { expect } = Code

// Things we need to stub
const CompensationChargeTransactionPresenter = require('../../../app/presenters/bill-licences/compensation-charge-transaction.presenter.js')
const MinimumChargeTransactionPresenter = require('../../../app/presenters/bill-licences/minimum-charge-transaction.presenter.js')
const StandardChargeTransactionPresenter = require('../../../app/presenters/bill-licences/standard-charge-transaction.presenter.js')
const ViewCompensationChargeTransactionPresenter = require('../../../app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js')
const ViewMinimumChargeTransactionPresenter = require('../../../app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js')
const ViewStandardChargeTransactionPresenter = require('../../../app/presenters/bill-licences/view-standard-charge-transaction.presenter.js')

// Thing under test
const ViewBillLicencePresenter = require('../../../app/presenters/bill-licences/view-bill-licence.presenter.js')
Expand All @@ -27,9 +27,9 @@ describe('View Bill Licence presenter', () => {
beforeEach(() => {
billLicence = _testBillLicence()

Sinon.stub(CompensationChargeTransactionPresenter, 'go').returns({ chargeType: 'compensation' })
Sinon.stub(MinimumChargeTransactionPresenter, 'go').returns({ chargeType: 'minimum_charge' })
Sinon.stub(StandardChargeTransactionPresenter, 'go').returns({ chargeType: 'standard' })
Sinon.stub(ViewCompensationChargeTransactionPresenter, 'go').returns({ chargeType: 'compensation' })
Sinon.stub(ViewMinimumChargeTransactionPresenter, 'go').returns({ chargeType: 'minimum_charge' })
Sinon.stub(ViewStandardChargeTransactionPresenter, 'go').returns({ chargeType: 'standard' })
})

describe("the 'displayCreditDebitTotals' property", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { describe, it, beforeEach } = exports.lab = Lab.script()
const { expect } = Code

// Thing under test
const CompensationChargeTransactionPresenter = require('../../../app/presenters/bill-licences/compensation-charge-transaction.presenter.js')
const ViewCompensationChargeTransactionPresenter = require('../../../app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js')

describe('Compensation Charge Transaction presenter', () => {
describe('View Compensation Charge Transaction presenter', () => {
let transaction

describe('when provided with a compensation charge transaction', () => {
Expand All @@ -35,7 +35,7 @@ describe('Compensation Charge Transaction presenter', () => {
})

it('returns the credit property populated and the debit empty', () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result.creditAmount).to.equal('£214.74')
expect(result.debitAmount).to.equal('')
Expand All @@ -48,7 +48,7 @@ describe('Compensation Charge Transaction presenter', () => {
})

it('returns the debit property populated and the credit empty', () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result.creditAmount).to.equal('')
expect(result.debitAmount).to.equal('£214.74')
Expand All @@ -57,7 +57,7 @@ describe('Compensation Charge Transaction presenter', () => {

describe('that is for SROC', () => {
it('correctly presents the data', () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result).to.equal({
billableDays: '153/214',
Expand All @@ -83,23 +83,23 @@ describe('Compensation Charge Transaction presenter', () => {
})

it("returns 'Two-part tariff'", () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result.agreement).to.equal('Two-part tariff')
})
})

describe('when the transaction is not two-part tariff', () => {
it('returns null', () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result.agreement).to.be.null()
})
})
})

it('correctly presents the data', () => {
const result = CompensationChargeTransactionPresenter.go(transaction)
const result = ViewCompensationChargeTransactionPresenter.go(transaction)

expect(result).to.equal({
agreement: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { describe, it, beforeEach } = exports.lab = Lab.script()
const { expect } = Code

// Thing under test
const MinimumChargeTransactionPresenter = require('../../../app/presenters/bill-licences/minimum-charge-transaction.presenter.js')
const ViewMinimumChargeTransactionPresenter = require('../../../app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js')

describe('Minimum Charge Transaction presenter', () => {
describe('View Minimum Charge Transaction presenter', () => {
let transaction

describe('when provided with a minimum charge transaction', () => {
Expand All @@ -27,7 +27,7 @@ describe('Minimum Charge Transaction presenter', () => {
})

it('returns the credit property populated and the debit empty', () => {
const result = MinimumChargeTransactionPresenter.go(transaction)
const result = ViewMinimumChargeTransactionPresenter.go(transaction)

expect(result.creditAmount).to.equal('£24.01')
expect(result.debitAmount).to.equal('')
Expand All @@ -40,15 +40,15 @@ describe('Minimum Charge Transaction presenter', () => {
})

it('returns the debit property populated and the credit empty', () => {
const result = MinimumChargeTransactionPresenter.go(transaction)
const result = ViewMinimumChargeTransactionPresenter.go(transaction)

expect(result.creditAmount).to.equal('')
expect(result.debitAmount).to.equal('£24.01')
})
})

it('correctly presents the data', () => {
const result = MinimumChargeTransactionPresenter.go(transaction)
const result = ViewMinimumChargeTransactionPresenter.go(transaction)

expect(result).to.equal({
billableDays: '',
Expand Down
Loading
Loading