From 797307ed19d54fde0914a5e2a17a5e8a55b7ca57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 12 Dec 2024 09:39:37 +0000 Subject: [PATCH] feat: Use `getFeeBreakdown()` util for generating payload --- src/export/digitalPlanning/model.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/export/digitalPlanning/model.ts b/src/export/digitalPlanning/model.ts index 971918b0..fc20fc7c 100644 --- a/src/export/digitalPlanning/model.ts +++ b/src/export/digitalPlanning/model.ts @@ -16,6 +16,7 @@ import { SessionMetadata, Value, } from "../../types"; +import { getFeeBreakdown } from "../../utils"; import { extractFileDescriptionForPassportKey, formatProposalDetails, @@ -606,10 +607,11 @@ export class DigitalPlanning { }; } + const feeBreakdown = getFeeBreakdown(this.passport.data); + const baseFee = { - calculated: - (this.passport.data?.["application.fee.calculated"] as number) || 0, - payable: (this.passport.data?.["application.fee.payable"] as number) || 0, + calculated: feeBreakdown.amount.calculated, + payable: feeBreakdown.amount.payable, category: { one: (this.passport.data?.["application.fee.category.one"] as number) || 0, @@ -666,23 +668,13 @@ export class DigitalPlanning { ] as number) || 0, }, exemption: { - disability: this.stringToBool( - this.passport.data?.["application.fee.exemption.disability"]?.[0], - ), - resubmission: this.stringToBool( - this.passport.data?.["application.fee.exemption.resubmission"]?.[0], - ), + disability: feeBreakdown.exemptions.includes("disability"), + resubmission: feeBreakdown.exemptions.includes("resubmission"), }, reduction: { - sports: this.stringToBool( - this.passport.data?.["application.fee.reduction.sports"]?.[0], - ), - parishCouncil: this.stringToBool( - this.passport.data?.["application.fee.reduction.parishCouncil"]?.[0], - ), - alternative: this.stringToBool( - this.passport.data?.["application.fee.reduction.alternative"]?.[0], - ), + sports: feeBreakdown.reductions.includes("sports"), + parishCouncil: feeBreakdown.reductions.includes("parishCouncil"), + alternative: feeBreakdown.reductions.includes("alternative"), }, };