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

Fix issues with reissue post The Great Rename #664

Merged
merged 2 commits into from
Jan 17, 2024
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
19 changes: 17 additions & 2 deletions app/services/bill-runs/supplementary/reissue-bill.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,16 @@ function _retrieveOrGenerateBill (dataToReturn, sourceBill, reissueBillRun, char
}

const translatedChargingModuleInvoice = _mapChargingModuleInvoice(chargingModuleReissueInvoice)

// GenerateBillService expects a BillingAccount instance and was built for supplementary billing. We only have the
// Bill object. So, we create a 'billing account' from its data that GenerateBillService can then use.
const billingAccount = {
id: sourceBill.billingAccountId,
accountNumber: sourceBill.accountNumber
}

const generatedBill = GenerateBillService.go(
sourceBill,
billingAccount,
reissueBillRun.id,
sourceBill.financialYearEnding
)
Expand Down Expand Up @@ -267,7 +275,14 @@ function _retrieveOrGenerateBillLicence (dataToReturn, sourceBill, billingId, so
return existingBillLicence
}

const newBillLicence = GenerateBillLicenceService.go(billingId, sourceBillLicence)
// GenerateBillLicenceService expects a Licence object and was built for supplementary billing. We only have the
// BillLicence object. So, we create a 'licence' from its data that GenerateBillLicenceService can then use.
const licence = {
id: sourceBillLicence.licenceId,
licenceRef: sourceBillLicence.licenceRef
}

const newBillLicence = GenerateBillLicenceService.go(billingId, licence)

dataToReturn.billLicences.push(newBillLicence)

Expand Down
Loading