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

Amend 2PT friendly response following changes #361

Merged
merged 5 commits into from
Aug 17, 2023
Merged
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/services/check/friendly-response.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { formatAbstractionPeriod, formatLongDate } = require('../../presenters/ba

function go (billingPeriod, matchedChargeVersions) {
const response = {
note: 'This response aims to match the UI. Note this means the entity names and structure DO NOT match what is in the DB.',
billingPeriod: {
startDate: formatLongDate(billingPeriod.startDate),
endDate: formatLongDate(billingPeriod.endDate)
Expand All @@ -28,6 +29,7 @@ function _formatFriendlyLicences (licences, matchedChargeVersions) {
const friendlyLicence = {
id: licenceId,
licenceRef,
returnsStatuses: chargeVersions[0].returnStatuses,
chargeInformations: []
}

Expand Down Expand Up @@ -66,6 +68,7 @@ function _formatFriendlyChargeReferences (chargeReferences, chargeElements) {
eiucRegion,
isRestrictedSource,
loss,
returns,
source,
volume,
waterModel
Expand All @@ -89,9 +92,11 @@ function _formatFriendlyChargeReferences (chargeReferences, chargeElements) {
eiucRegion,
additionalCharges: formattedAdditionalCharges,
adjustments: formattedAdjustments,
chargeElements: []
chargeElements: [],
returns: []
}

_formatFriendlyReturns(friendlyChargeReference.returns, returns)
_formatFriendlyChargeElements(friendlyChargeReference.chargeElements, chargePurposes)

chargeReferences.push(friendlyChargeReference)
Expand All @@ -107,7 +112,6 @@ function _formatFriendlyChargeElements (chargeElements, chargePurposes) {
isSection127AgreementEnabled,
loss,
purposesUse,
returnStatus,
timeLimitedStartDate,
timeLimitedEndDate,
abstractionPeriodEndDay: endDay,
Expand All @@ -129,10 +133,6 @@ function _formatFriendlyChargeElements (chargeElements, chargePurposes) {
}

friendlyChargeElement.legacyId = purposesUse.legacyId
friendlyChargeElement.returnStatuses = returnStatus
friendlyChargeElement.returns = []

_formatFriendlyReturns(friendlyChargeElement.returns, chargePurpose.returns)

chargeElements.push(friendlyChargeElement)
})
Expand Down