Skip to content

Commit

Permalink
change totals in moving flow
Browse files Browse the repository at this point in the history
  • Loading branch information
panasetskaya committed Jan 2, 2025
1 parent 5468ad5 commit a60030f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
2 changes: 2 additions & 0 deletions app/data/data-changetier/src/test/kotlin/CommonTestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal val oldTestQuote = TierDeductibleQuote(
tierDescription = "Vårt paket med grundläggande villkor.",
tierDisplayName = "Bas",
),
addons = emptyList(),
productVariant = ProductVariant(
displayName = "Test",
contractGroup = ContractGroup.RENTAL,
Expand Down Expand Up @@ -64,6 +65,7 @@ internal val testQuote = TierDeductibleQuote(
tierDescription = "Vårt paket med grundläggande villkor.",
tierDisplayName = "Bas",
),
addons = emptyList(),
productVariant = ProductVariant(
displayName = "Test",
contractGroup = ContractGroup.RENTAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private fun SummarySuccessScreen(
.padding(horizontal = 16.dp),
)
Spacer(Modifier.height(8.dp))
for (addon in uiState.quote.addons) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
for (addon in uiState.quote.addons) {
AddonCard(
addonQuote = addon,
activationDate = uiState.activationDate,
Expand All @@ -215,8 +215,10 @@ private fun SummarySuccessScreen(
spaceBetween = 8.dp,
endSlot = {
HedvigText(
text = stringResource(R.string.TERMINATION_FLOW_PAYMENT_PER_MONTH,
uiState.total.amount.toInt()),
text = stringResource(
R.string.TERMINATION_FLOW_PAYMENT_PER_MONTH,
uiState.total.amount.toInt(),
),
textAlign = TextAlign.End,
style = HedvigTheme.typography.bodySmall,
)
Expand Down Expand Up @@ -394,7 +396,6 @@ private class ChooseInsuranceUiStateProvider :
activeDisplayPremium = "449 kr",
),
activationDate = LocalDate(2024, 5, 1),
total = UiMoney(685.0, SEK),
quote = TierDeductibleQuote(
id = "id4",
deductible = Deductible(
Expand Down Expand Up @@ -422,7 +423,7 @@ private class ChooseInsuranceUiStateProvider :
tierDescription = "Our most standard coverage",
termsVersion = "SE_DOG_STANDARD-20230330-HEDVIG-null",
),
addons = listOf(
addons = List(2) {
ChangeTierDeductibleAddonQuote(
addonId = "addonId",
displayName = "Addon Quote Name",
Expand All @@ -434,7 +435,7 @@ private class ChooseInsuranceUiStateProvider :
),
),
previousPremium = UiMoney(29.0, SEK),
premium = UiMoney(30.0, SEK),
premium = UiMoney(45.0, SEK),
addonVariant = AddonVariant(
displayName = "Addon Name",
perils = listOf(),
Expand All @@ -449,8 +450,8 @@ private class ChooseInsuranceUiStateProvider :
termsVersion = "RESESKYDD-20230330-HEDVIG-null",
product = "product",
),
),
),
)
},
),
),
Failure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,10 @@ private class SummaryPresenter(
contractDisplayName = currentQuoteToChange.productVariant.displayName,
contractDisplaySubtitle = currentContractData.currentExposureName,
)
var total = rightQuote.premium.amount
rightQuote.addons.forEach {
total += it.premium.amount
}
currentState = Success(
quote = rightQuote,
currentContractData = currentContract,
activationDate = params.activationDate,
total = UiMoney(total, rightQuote.premium.currencyCode)
)
}
},
Expand All @@ -149,9 +144,14 @@ internal sealed interface SummaryState {
val quote: TierDeductibleQuote,
val currentContractData: ContractData,
val activationDate: LocalDate,
val total: UiMoney,
val navigateToFail: Boolean = false,
) : SummaryState
) : SummaryState {
val total: UiMoney = quote.addons.map { it.premium }.plus(quote.premium)
.sumOf { it.amount }
.let { sum ->
UiMoney(sum, quote.premium.currencyCode)
}
}

data object Failure : SummaryState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,28 @@ private class SummaryUiStateProvider : PreviewParameterProvider<SummaryUiState>
displayItems = emptyList(),
relatedAddonQuotes = emptyList(),
),
MoveMtaQuote(
premium = UiMoney(23.0, SEK),
exposureName = "exposureName",
productVariant = productVariant,
startDate = startDate,
displayItems = emptyList(),
relatedAddonQuotes = listOf(
AddonQuote(
premium = UiMoney(30.0, SEK),
startDate = startDate,
displayItems = listOf(
DisplayItem(
title = "display title",
subtitle = "display subtitle",
value = "display value",
),
),
exposureName = "exposureName",
addonVariant = addonVariant,
),
),
),
),
),
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,29 @@ internal data class SummaryInfo(
val moveHomeQuote: MoveHomeQuote,
val moveMtaQuotes: List<MoveMtaQuote>,
) {
val totalPremium: UiMoney = moveMtaQuotes.map { it.premium }.plus(moveHomeQuote.premium)
private val homeQuoteWithAddonsPremium = moveHomeQuote.relatedAddonQuotes.map {
it.premium
}.plus(moveHomeQuote.premium)
.sumOf { it.amount }
.let { sum ->
UiMoney(sum, moveHomeQuote.premium.currencyCode)
}
private val mtaQuotesPremiums = moveMtaQuotes.map {
it.premium
}.sumOf { it.amount }
.let { sum ->
UiMoney(sum, moveHomeQuote.premium.currencyCode)
}
private val mtaQuotesAddonsPremiums = moveMtaQuotes.flatMap { it.relatedAddonQuotes }.map {
it.premium
}.sumOf { it.amount }
.let { sum ->
UiMoney(sum, moveHomeQuote.premium.currencyCode)
}
val totalPremium: UiMoney =
UiMoney(
listOf(homeQuoteWithAddonsPremium, mtaQuotesPremiums, mtaQuotesAddonsPremiums)
.sumOf { it.amount },
moveHomeQuote.premium.currencyCode,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ private val testQuote = TierDeductibleQuote(
tierDescription = "Vårt paket med grundläggande villkor.",
tierDisplayName = "Bas",
),
addons = emptyList(),
productVariant = ProductVariant(
displayName = "Test",
contractGroup = RENTAL,
Expand Down

0 comments on commit a60030f

Please sign in to comment.