Skip to content

Commit

Permalink
Replace Deposit with Payout in all class names
Browse files Browse the repository at this point in the history
  • Loading branch information
malinajirka committed Nov 20, 2024
1 parent 4cf7044 commit 2ce6e1d
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PaymentsHubAdapter :
PaymentsHubViewHolder.LearnMoreViewHolder(parent)
}
VIEW_TYPE_DEPOSIT_SUMMARY -> {
PaymentsHubViewHolder.DepositSummaryViewHolder(ComposeView(parent.context))
PaymentsHubViewHolder.PayoutSummaryViewHolder(ComposeView(parent.context))
}
else -> error("Unknown section")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.woocommerce.android.databinding.CardReaderLearnMoreSectionBinding
import com.woocommerce.android.databinding.PaymentsHubHeaderBinding
import com.woocommerce.android.databinding.PaymentsHubListItemBinding
import com.woocommerce.android.databinding.PaymentsHubToggelableItemBinding
import com.woocommerce.android.ui.payments.hub.depositsummary.PaymentsHubDepositSummaryView
import com.woocommerce.android.ui.payments.hub.payoutsummary.PaymentsHubPayoutSummaryView
import com.woocommerce.android.util.UiHelpers

private const val DISABLED_BUTTON_ALPHA = 0.5f
Expand Down Expand Up @@ -122,10 +122,10 @@ abstract class PaymentsHubViewHolder(val view: View) : RecyclerView.ViewHolder(v
}
}

class DepositSummaryViewHolder(private val composeView: ComposeView) : PaymentsHubViewHolder(composeView) {
class PayoutSummaryViewHolder(private val composeView: ComposeView) : PaymentsHubViewHolder(composeView) {
override fun onBind(uiState: PaymentsHubViewState.ListItem) {
composeView.setContent {
PaymentsHubDepositSummaryView()
PaymentsHubPayoutSummaryView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woocommerce.android.ui.payments.hub.depositsummary
package com.woocommerce.android.ui.payments.hub.payoutsummary

import com.woocommerce.android.tools.SelectedSite
import kotlinx.coroutines.flow.flow
Expand All @@ -7,7 +7,7 @@ import org.wordpress.android.fluxc.network.rest.wpcom.wc.WooError
import org.wordpress.android.fluxc.store.WCWooPaymentsStore
import javax.inject.Inject

class PaymentsHubDepositSummaryRepository @Inject constructor(
class PaymentsHubPayoutSummaryRepository @Inject constructor(
private val store: WCWooPaymentsStore,
private val site: SelectedSite,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.woocommerce.android.ui.payments.hub.depositsummary
package com.woocommerce.android.ui.payments.hub.payoutsummary

import org.wordpress.android.fluxc.network.rest.wpcom.wc.WooError
import java.util.SortedMap

sealed class PaymentsHubDepositSummaryState {
object Loading : PaymentsHubDepositSummaryState()
data class Error(val error: WooError) : PaymentsHubDepositSummaryState()
sealed class PaymentsHubPayoutSummaryState {
object Loading : PaymentsHubPayoutSummaryState()
data class Error(val error: WooError) : PaymentsHubPayoutSummaryState()
data class Success(
val overview: Overview,
val fromCache: Boolean,
val onLearnMoreClicked: () -> Unit,
val onExpandCollapseClicked: (Boolean) -> Unit,
val onCurrencySelected: (String) -> Unit,
) : PaymentsHubDepositSummaryState()
) : PaymentsHubPayoutSummaryState()

data class Overview(
val defaultCurrency: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.woocommerce.android.ui.payments.hub.depositsummary
package com.woocommerce.android.ui.payments.hub.payoutsummary

import com.woocommerce.android.extensions.formatToDDMMMYYYY
import com.woocommerce.android.util.CurrencyFormatter
import org.wordpress.android.fluxc.model.payments.woo.WooPaymentsDepositsOverview
import java.util.Date
import javax.inject.Inject

class PaymentsHubDepositSummaryStateMapper @Inject constructor(
class PaymentsHubPayoutSummaryStateMapper @Inject constructor(
private val currencyFormatter: CurrencyFormatter,
private val dateFormatter: DateToDDMMMYYYYStringFormatter
) {
Expand All @@ -30,10 +30,10 @@ class PaymentsHubDepositSummaryStateMapper @Inject constructor(
Result.InvalidInputData
} else {
Result.Success(
PaymentsHubDepositSummaryState.Overview(
PaymentsHubPayoutSummaryState.Overview(
defaultCurrency = defaultCurrency,
infoPerCurrency = currencies.associateWith { currency ->
PaymentsHubDepositSummaryState.Info(
PaymentsHubPayoutSummaryState.Info(
availableFundsFormatted = formatMoney(
amount = availableBalances.firstOrNull { it.currency == currency }?.amount ?: 0,
currency = currency
Expand All @@ -42,7 +42,8 @@ class PaymentsHubDepositSummaryStateMapper @Inject constructor(
amount = pendingBalances.firstOrNull { it.currency == currency }?.amount ?: 0,
currency = currency
),
availableFundsAmount = availableBalances.firstOrNull { it.currency == currency }?.amount ?: 0,
availableFundsAmount = availableBalances.firstOrNull { it.currency == currency }?.amount
?: 0,
pendingFundsAmount = pendingBalances.firstOrNull { it.currency == currency }?.amount ?: 0,
fundsAvailableInDays = overview.account?.depositsSchedule?.delayDays,
fundsDepositInterval = overview.account.fundsAvailableIn(),
Expand All @@ -59,7 +60,7 @@ class PaymentsHubDepositSummaryStateMapper @Inject constructor(
}

private fun mapDeposit(info: WooPaymentsDepositsOverview.Deposit.Info) =
PaymentsHubDepositSummaryState.Deposit(
PaymentsHubPayoutSummaryState.Deposit(
amount = formatMoney(info.amount ?: 0L, info.currency.orEmpty()),
status = info.status.toDepositStatus(),
date = if (info.date != null) dateFormatter(Date(info.date!!)) else ""
Expand All @@ -72,14 +73,14 @@ class PaymentsHubDepositSummaryStateMapper @Inject constructor(
)

@Suppress("ReturnCount")
private fun WooPaymentsDepositsOverview.Account?.fundsAvailableIn(): PaymentsHubDepositSummaryState.Info.Interval? {
private fun WooPaymentsDepositsOverview.Account?.fundsAvailableIn(): PaymentsHubPayoutSummaryState.Info.Interval? {
return when (this?.depositsSchedule?.interval?.lowercase()) {
"daily" -> PaymentsHubDepositSummaryState.Info.Interval.Daily
"weekly" -> PaymentsHubDepositSummaryState.Info.Interval.Weekly(
"daily" -> PaymentsHubPayoutSummaryState.Info.Interval.Daily
"weekly" -> PaymentsHubPayoutSummaryState.Info.Interval.Weekly(
this.depositsSchedule?.weeklyAnchor ?: return null
)

"monthly" -> PaymentsHubDepositSummaryState.Info.Interval.Monthly(
"monthly" -> PaymentsHubPayoutSummaryState.Info.Interval.Monthly(
this.depositsSchedule?.monthlyAnchor ?: return null
)

Expand All @@ -89,17 +90,17 @@ class PaymentsHubDepositSummaryStateMapper @Inject constructor(

private fun String?.toDepositStatus() =
when (this?.uppercase()) {
"ESTIMATED" -> PaymentsHubDepositSummaryState.Deposit.Status.ESTIMATED
"PENDING" -> PaymentsHubDepositSummaryState.Deposit.Status.PENDING
"IN_TRANSIT" -> PaymentsHubDepositSummaryState.Deposit.Status.IN_TRANSIT
"PAID" -> PaymentsHubDepositSummaryState.Deposit.Status.PAID
"CANCELED" -> PaymentsHubDepositSummaryState.Deposit.Status.CANCELED
"FAILED" -> PaymentsHubDepositSummaryState.Deposit.Status.FAILED
else -> PaymentsHubDepositSummaryState.Deposit.Status.UNKNOWN
"ESTIMATED" -> PaymentsHubPayoutSummaryState.Deposit.Status.ESTIMATED
"PENDING" -> PaymentsHubPayoutSummaryState.Deposit.Status.PENDING
"IN_TRANSIT" -> PaymentsHubPayoutSummaryState.Deposit.Status.IN_TRANSIT
"PAID" -> PaymentsHubPayoutSummaryState.Deposit.Status.PAID
"CANCELED" -> PaymentsHubPayoutSummaryState.Deposit.Status.CANCELED
"FAILED" -> PaymentsHubPayoutSummaryState.Deposit.Status.FAILED
else -> PaymentsHubPayoutSummaryState.Deposit.Status.UNKNOWN
}

sealed class Result {
data class Success(val overview: PaymentsHubDepositSummaryState.Overview) : Result()
data class Success(val overview: PaymentsHubPayoutSummaryState.Overview) : Result()
object InvalidInputData : Result()
}
}
Expand Down
Loading

0 comments on commit 2ce6e1d

Please sign in to comment.