Skip to content

Commit

Permalink
Merge pull request #328 from DFE-Digital/feature/default-sponsored-gr…
Browse files Browse the repository at this point in the history
…ant-amounts

Nullify reason if amount changed is false
  • Loading branch information
dneed-nimble authored Sep 4, 2023
2 parents 206b588 + e45e7ef commit 4dad395
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Dfe.Academies.Academisation.Domain/ProjectAggregate/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public CommandResult Update(ProjectDetails detailsToUpdate)
ProposedAcademyOpeningDate = detailsToUpdate.ProposedAcademyOpeningDate,
SchoolAndTrustInformationSectionComplete = detailsToUpdate.SchoolAndTrustInformationSectionComplete,
ConversionSupportGrantAmount = CalculateDefaultSponsoredGrant(Details.ConversionSupportGrantType, detailsToUpdate.ConversionSupportGrantType, detailsToUpdate.ConversionSupportGrantAmount),
ConversionSupportGrantChangeReason = detailsToUpdate.ConversionSupportGrantChangeReason,
ConversionSupportGrantChangeReason = NullifyGrantChangeReasonIfNeeded(detailsToUpdate.ConversionSupportGrantAmountChanged, detailsToUpdate.ConversionSupportGrantChangeReason),
ConversionSupportGrantType = detailsToUpdate.ConversionSupportGrantType,
ConversionSupportGrantEnvironmentalImprovementGrant = detailsToUpdate.ConversionSupportGrantEnvironmentalImprovementGrant,
ConversionSupportGrantAmountChanged = detailsToUpdate.ConversionSupportGrantAmountChanged,
Expand Down Expand Up @@ -348,4 +348,12 @@ public CommandResult Update(ProjectDetails detailsToUpdate)
_ => currentAmount
};
}
protected string? NullifyGrantChangeReasonIfNeeded(bool? grantAmountChanged, string? reason)
{
return grantAmountChanged switch
{
true => reason,
false => null
};
}
}

0 comments on commit 4dad395

Please sign in to comment.