forked from shihaam/thijooree
seperate mvr and usd blocked funds in dashboard
This commit is contained in:
@@ -278,26 +278,23 @@ class DashboardFragment : Fragment() {
|
|||||||
.groupBy({ it.first }, { it.second })
|
.groupBy({ it.first }, { it.second })
|
||||||
.mapValues { (_, vs) -> vs.sum() }
|
.mapValues { (_, vs) -> vs.sum() }
|
||||||
|
|
||||||
|
val blockedMvr = blockedByCurrency["MVR"] ?: 0.0
|
||||||
|
val blockedUsd = blockedByCurrency["USD"] ?: 0.0
|
||||||
val blockedTotal = blockedByCurrency.values.sum()
|
val blockedTotal = blockedByCurrency.values.sum()
|
||||||
if (blockedTotal > 0.0) {
|
|
||||||
// Primary line: prefer MVR if present, otherwise the first currency.
|
|
||||||
val primaryCcy = if ("MVR" in blockedByCurrency) "MVR" else blockedByCurrency.keys.first()
|
|
||||||
val primaryAmt = blockedByCurrency.getValue(primaryCcy)
|
|
||||||
binding.tvBlockedTotal.text = if (hide) "$primaryCcy ••••••" else "$primaryCcy %,.2f".format(primaryAmt)
|
|
||||||
|
|
||||||
val secondary = blockedByCurrency.filterKeys { it != primaryCcy }
|
if (blockedMvr > 0.0) {
|
||||||
if (secondary.isNotEmpty()) {
|
binding.tvBlockedMvr.text = if (hide) "MVR ••••••" else "MVR %,.2f".format(blockedMvr)
|
||||||
binding.tvBlockedSecondary.text = secondary.entries.joinToString(" · ") { (ccy, amt) ->
|
binding.cardBlockedMvr.visibility = View.VISIBLE
|
||||||
if (hide) "$ccy ••••••" else "$ccy %,.2f".format(amt)
|
|
||||||
}
|
|
||||||
binding.tvBlockedSecondary.visibility = View.VISIBLE
|
|
||||||
} else {
|
|
||||||
binding.tvBlockedSecondary.visibility = View.GONE
|
|
||||||
}
|
|
||||||
binding.cardBlocked.visibility = View.VISIBLE
|
|
||||||
} else {
|
} else {
|
||||||
binding.cardBlocked.visibility = View.GONE
|
binding.cardBlockedMvr.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
if (blockedUsd > 0.0) {
|
||||||
|
binding.tvBlockedUsd.text = if (hide) "USD ••••••" else "USD %,.2f".format(blockedUsd)
|
||||||
|
binding.cardBlockedUsd.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
binding.cardBlockedUsd.visibility = View.GONE
|
||||||
|
}
|
||||||
|
binding.rowBlocked.visibility = if (blockedTotal > 0.0) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
// Overdue: MIB finance deals + BML loan details (assumed MVR — matches existing Pending Finances).
|
// Overdue: MIB finance deals + BML loan details (assumed MVR — matches existing Pending Finances).
|
||||||
val mibOverdue = (viewModel.financing.value ?: emptyList()).sumOf { it.overdueAmount }
|
val mibOverdue = (viewModel.financing.value ?: emptyList()).sumOf { it.overdueAmount }
|
||||||
@@ -310,8 +307,7 @@ class DashboardFragment : Fragment() {
|
|||||||
binding.cardOverdue.visibility = View.GONE
|
binding.cardOverdue.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.rowAttention.visibility =
|
binding.rowAttention.visibility = if (overdueTotal > 0.0) View.VISIBLE else View.GONE
|
||||||
if (blockedTotal > 0.0 || overdueTotal > 0.0) View.VISIBLE else View.GONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePendingFinances() {
|
private fun updatePendingFinances() {
|
||||||
|
|||||||
@@ -176,9 +176,9 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Attention row: Blocked + Overdue (hidden when nothing applies) -->
|
<!-- Blocked funds row: MVR + USD separate cards (hidden when no blocked amounts) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/rowAttention"
|
android:id="@+id/rowBlocked"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cardBlocked"
|
android:id="@+id/cardBlockedMvr"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -205,12 +205,12 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/dashboard_blocked"
|
android:text="@string/dashboard_blocked_mvr"
|
||||||
android:textAppearance="?attr/textAppearanceLabelSmall"
|
android:textAppearance="?attr/textAppearanceLabelSmall"
|
||||||
android:textColor="?attr/colorOnErrorContainer" />
|
android:textColor="?attr/colorOnErrorContainer" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvBlockedTotal"
|
android:id="@+id/tvBlockedMvr"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
@@ -218,22 +218,12 @@
|
|||||||
android:textAppearance="?attr/textAppearanceTitleMedium"
|
android:textAppearance="?attr/textAppearanceTitleMedium"
|
||||||
android:textColor="?attr/colorOnErrorContainer" />
|
android:textColor="?attr/colorOnErrorContainer" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvBlockedSecondary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:textAppearance="?attr/textAppearanceLabelSmall"
|
|
||||||
android:textColor="?attr/colorOnErrorContainer"
|
|
||||||
android:alpha="0.75"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cardOverdue"
|
android:id="@+id/cardBlockedUsd"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -241,6 +231,52 @@
|
|||||||
app:cardElevation="1dp"
|
app:cardElevation="1dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="12dp"
|
||||||
app:cardBackgroundColor="?attr/colorErrorContainer"
|
app:cardBackgroundColor="?attr/colorErrorContainer"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dashboard_blocked_usd"
|
||||||
|
android:textAppearance="?attr/textAppearanceLabelSmall"
|
||||||
|
android:textColor="?attr/colorOnErrorContainer" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvBlockedUsd"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="USD —"
|
||||||
|
android:textAppearance="?attr/textAppearanceTitleMedium"
|
||||||
|
android:textColor="?attr/colorOnErrorContainer" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Overdue row (hidden when no overdue financing) -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/rowAttention"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:id="@+id/cardOverdue"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardElevation="1dp"
|
||||||
|
app:cardCornerRadius="12dp"
|
||||||
|
app:cardBackgroundColor="?attr/colorErrorContainer"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|||||||
@@ -218,7 +218,8 @@
|
|||||||
<string name="cards">Cards</string>
|
<string name="cards">Cards</string>
|
||||||
<string name="available_balance">Available Balance</string>
|
<string name="available_balance">Available Balance</string>
|
||||||
<string name="account_blocked_label">%1$s blocked</string>
|
<string name="account_blocked_label">%1$s blocked</string>
|
||||||
<string name="dashboard_blocked">Blocked Funds</string>
|
<string name="dashboard_blocked_mvr">Blocked MVR</string>
|
||||||
|
<string name="dashboard_blocked_usd">Blocked USD</string>
|
||||||
<string name="dashboard_overdue">Overdue Financing</string>
|
<string name="dashboard_overdue">Overdue Financing</string>
|
||||||
|
|
||||||
<!-- Transfer -->
|
<!-- Transfer -->
|
||||||
|
|||||||
Reference in New Issue
Block a user