Skip to content

Commit

Permalink
feat: Use getFeeBreakdown() util for generating payload
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 12, 2024
1 parent 29b4851 commit 797307e
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/export/digitalPlanning/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
SessionMetadata,
Value,
} from "../../types";
import { getFeeBreakdown } from "../../utils";
import {
extractFileDescriptionForPassportKey,
formatProposalDetails,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
},
};

Expand Down

0 comments on commit 797307e

Please sign in to comment.