Skip to content

Commit

Permalink
Merge branch 'beneficiary_screen_in_compose' of https://github.com/Ud…
Browse files Browse the repository at this point in the history
…uakUmanah10/mifos-mobile into beneficiary_screen_in_compose
  • Loading branch information
UduakUmanah10 committed Mar 22, 2024
2 parents 27324a8 + 0243a11 commit a3030e8
Show file tree
Hide file tree
Showing 50 changed files with 1,975 additions and 1,727 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ An Android Application built on top of the MifosX Self-Service platform for end-

## Join Us on Slack

Mifos boasts an active and vibrant contributor community, Please join us on [slack](https://mifos.slack.com/). Once you've joined the mifos slack community, please join the `#mifos-mobile` channel to engage with mifos-mobile development. If you encounter any difficulties joining our Slack channel, please don't hesitate to open an issue. This will allow us to assist you promptly or send you an invitation.
Mifos boasts an active and vibrant contributor community, Please join us on [slack](https://join.slack.com/t/mifos/shared_invite/zt-2f4nr6tk3-ZJlHMi1lc0R19FFEHxdvng). Once you've joined the mifos slack community, please join the `#mifos-mobile` channel to engage with mifos-mobile development. If you encounter any difficulties joining our Slack channel, please don't hesitate to open an issue. This will allow us to assist you promptly or send you an invitation.



Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ dependencies {
testImplementation(libs.junit)
testImplementation("org.mockito:mockito-core:5.4.0")
implementation("org.mockito:mockito-core:5.4.0")
//turbine
testImplementation("app.cash.turbine:turbine:1.1.0")
implementation("org.mockito:mockito-android:5.4.0")
androidTestImplementation((libs.junit))
androidTestImplementation("org.mockito:mockito-core:5.4.0")
Expand Down
16 changes: 16 additions & 0 deletions app/src/debug/java/org/mifos/mobile/api/ObserveUiState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.mifos.mobile.api

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.mifos.mobile.utils.BeneficiaryUiState

//fun TestScope.obserrveUiState(): MutableList<BeneficiaryUiState> {
// val uiStates = mutableListOf<BeneficiaryUiState>()
// viewModel.beneficiaryUiState.onEach {
// println(it)
// uiStates.add(it)
// }
// .launchIn(CoroutineScope(UnconfinedTestDispatcher(testScheduler)))
// return uiStates
//}
8 changes: 4 additions & 4 deletions app/src/main/java/org/mifos/mobile/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class HomeViewModel @Inject constructor(private val homeRepositoryImp: HomeRepos
*/
private fun getLoanAccountDetails(loanAccountList: List<LoanAccount>): Double {
var totalAmount = 0.0
for ((_, _, _, _, _, _, _, _, _, _, _, _, _, _, loanBalance) in loanAccountList) {
totalAmount += loanBalance
for (loanAccount in loanAccountList) {
totalAmount += loanAccount.loanBalance
}
return totalAmount
}
Expand All @@ -124,8 +124,8 @@ class HomeViewModel @Inject constructor(private val homeRepositoryImp: HomeRepos
*/
private fun getSavingAccountDetails(savingAccountList: List<SavingAccount>?): Double {
var totalAmount = 0.0
for ((_, _, _, _, _, accountBalance) in savingAccountList!!) {
totalAmount += accountBalance
for (savingAccount in savingAccountList!!) {
totalAmount += savingAccount.accountBalance
}
return totalAmount
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mifos.mobile.viewModels

import android.util.Log
import android.view.View
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand All @@ -26,9 +27,9 @@ class BeneficiaryApplicationViewModel @Inject constructor(private val beneficiar

fun loadBeneficiaryTemplate() {
viewModelScope.launch {
_beneficiaryUiState.value = BeneficiaryUiState.Loading
_beneficiaryUiState.value = BeneficiaryUiState.Loading
beneficiaryRepositoryImp.beneficiaryTemplate().catch {
_beneficiaryUiState.value =
_beneficiaryUiState.value =
BeneficiaryUiState.ShowError(R.string.error_fetching_beneficiary_template)
}.onCompletion {
_beneficiaryUiState.value = BeneficiaryUiState.SetVisibility(View.VISIBLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ThirdPartyTransferViewModel @Inject constructor(
) :
ViewModel() {

private lateinit var accountOptionAndBeneficiary: AccountOptionAndBeneficiary
lateinit var accountOptionAndBeneficiary: AccountOptionAndBeneficiary

private val _thirdPartyTransferUiState = MutableStateFlow<ThirdPartyTransferUiState>(ThirdPartyTransferUiState.Initial)
val thirdPartyTransferUiState: StateFlow<ThirdPartyTransferUiState> get() = _thirdPartyTransferUiState
Expand All @@ -51,6 +51,7 @@ class ThirdPartyTransferViewModel @Inject constructor(
)

} catch (e: Throwable) {
println(e)
_thirdPartyTransferUiState.value =
ThirdPartyTransferUiState.Error(R.string.error_fetching_third_party_transfer_template)
}
Expand Down
32 changes: 16 additions & 16 deletions app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<string name="small_text">ছোট টেক্সট</string>
<string name="client_accounts">গ্রাহক অ্যাকাউন্ট</string>
<string name="splash">স্বাগতম পর্দা</string>
<string name="savings">রক্ষা</string>
<string name="savings">সঞ্চয়</string>
<string name="loan">ঋণ</string>
<string name="loan_account">ক্রেডিট অ্যাকাউন্ট</string>
<string name="share">ভাগ</string>
<string name="share">শেয়ার</string>
<string name="share_account">আপনার অ্যাকাউন্ট শেয়ার করুন</string>
<string name="clients_list">একটি গ্রাহক চয়ন করুন</string>
<string name="working">কাজ</string>
Expand All @@ -57,7 +57,7 @@
<string name="withdraw_loan_reason">ঋণ পরিশোধ করার কারণ</string>
<string name="loan_account_withdrawn_successfully">ঋণ অ্যাকাউন্ট সফলভাবে প্রত্যাহার করা হয়েছে</string>
<string name="submit_loan">একটি ঋণ জমা দিন</string>
<string name="new_loan_application">জন্য নতুন ক্রেডিট আবেদন</string>
<string name="new_loan_application">নতুন ঋণ ক্রেডিট আবেদন</string>
<string name="update_loan_application">আপনার ক্রেডিট আবেদন আপডেট করুন</string>
<string name="loan_interest_type">আগ্রহের ধরন</string>
<string name="amortization">ঘাত-শোষণ</string>
Expand Down Expand Up @@ -95,7 +95,7 @@
<string name="choose_transfer_type">স্থানান্তর ধরনের নির্বাচন করুন</string>
<string name="transfer_to_savings">সঞ্চয় স্থানান্তর</string>
<string name="transfer_from_savings">সঞ্চয় থেকে স্থানান্তর</string>
<string name="loan_charges">ঋণ জন্য ফি</string>
<string name="loan_charges">ঋণের জন্য ফি</string>
<string name="savings_charges">জমা</string>
<string name="active">সক্রিয়</string>
<string name="closed">বন্ধ</string>
Expand All @@ -118,7 +118,7 @@
<string name="rb_email">ই-মেল ঠিকানা</string>
<string name="verification_mode">যাচাই মোড</string>
<string name="blank">খালি</string>
<string name="import_qr">আমদানি QR</string>
<string name="import_qr">ইমপোর্ট QR</string>
<string name="view_guarantor">গ্যারান্টি দেখুন</string>
<string name="add_guarantor">একটি গ্যারান্টি যোগ করুন</string>
<string name="delete_guarantor">গ্যারান্টি সরান</string>
Expand All @@ -139,7 +139,7 @@
<string name="empty_transactions">আপনার সাথে কোন লেনদেন আছে</string>
<string name="empty_repayment_schedule">আপনার সাথে যুক্ত কোন পরিশোধের সময়সূচী নেই</string>
<string name="no_more_transactions_available">কোন লেনদেন উপলব্ধ নেই</string>
<string name="no_transaction">কোন লেনদেন</string>
<string name="no_transaction">কোন লেনদেন </string>
<string name="no_dob_found">DOB পাওয়া যায় নি।</string>
<string name="not_assigned_with_any_group">কোন গ্রুপ থেকে unassigned</string>

Expand Down Expand Up @@ -197,7 +197,7 @@
<string name="account_status">অ্যাকাউন্টের অবস্থা</string>
<string name="saving_product_name">পণ্যের নাম</string>
<string name="total_withdrawal">মোট পেমেন্ট</string>
<string name="min_required_balance">মি। প্রয়োজনীয় বল।</string>
<string name="min_required_balance">ন্যূনতম প্রয়োজনীয় ব্যালেন্স</string>
<string name="loan_product_name">পণ্যের নাম</string>
<string name="loan_purpose">ঋণ উদ্দেশ্য</string>
<string name="principal">পরিচালক</string>
Expand Down Expand Up @@ -244,9 +244,9 @@
<string name="loan_application_withdrawn_successfully">ঋণ আবেদন সফলভাবে প্রত্যাহার</string>
<string name="none">কিছু না</string>
<string name="all">সব</string>
<string name="four_weeks">4 সপ্তাহ</string>
<string name="three_months">তিন মাস</string>
<string name="six_months">6 মাস</string>
<string name="four_weeks"> সপ্তাহ</string>
<string name="three_months"> মাস</string>
<string name="six_months"> মাস</string>
<string name="filter">ফিল্টার</string>
<string name="start_date">শুরু তারিখ</string>
<string name="end_date">সমাপ্তির তারিখ</string>
Expand All @@ -265,7 +265,7 @@
<string name="internet_not_connected">আপনি একটি ইন্টারনেট সংযোগ আছে তা নিশ্চিত করুন</string>
<string name="beneficiary">উত্তরাধিকারী</string>
<string name="manage_beneficiaries">উত্তরাধিকার পরিচালনা করুন</string>
<string name="beneficiaries">ইসরাঈলের</string>
<string name="beneficiaries">সুবিধাভোগী</string>
<string name="beneficiary_detail">উত্তরাধিকার বিবরণ</string>
<string name="beneficiary_name">উত্তরাধিকারীর নাম</string>
<string name="account_type">অ্যাকাউন্ট টাইপ</string>
Expand All @@ -292,7 +292,7 @@
<string name="accounts_overview">অ্যাকাউন্ট ওভারভিউ</string>
<string name="show_hide_total_loan_amount">মোট ঋণের পরিমাণ দেখান বা লুকান</string>
<string name="hidden_amount">*****</string>
<string name="survey">সার্ভের</string>
<string name="survey">সার্ভে</string>
<string name="activation_date">অ্যাক্টিভেশন তারিখ</string>
<string name="groups">গ্রুপ</string>
<string name="user_details">ব্যবহারকারীর তথ্য</string>
Expand All @@ -303,11 +303,11 @@
<string name="invalid_qr">আপনি আপনার অ্যাকাউন্টে কর্ম সঞ্চালন করতে পারবেন না, সঞ্চয় অ্যাকাউন্ট থেকে QR কোড স্ক্যান করুন অথবা অন্য ব্যবহারকারীর ঋণ অ্যাকাউন্ট স্ক্যান করুন</string>
<string name="add">যোগ</string>
<string name="scan">স্ক্যান</string>
<string name="enter_passcode">4-সংখ্যার অ্যাক্সেস কোডটি প্রবেশ করান</string>
<string name="error_passcode">অ্যাক্সেস কোড 4 ডিজিট গঠিত হওয়া উচিত</string>
<string name="enter_passcode">সংখ্যার অ্যাক্সেস কোডটি প্রবেশ করান</string>
<string name="error_passcode">অ্যাক্সেস কোড ডিজিট হওয়া উচিত</string>
<string name="incorrect_passcode">ভুল অ্যাক্সেস কোড</string>
<string name="incorrect_passcode_more_than_three">আপনি 3 বার বেশি ভুল অ্যাক্সেস কোড প্রবেশ করেছেন</string>
<string name="skip">লাফালাফি করা</string>
<string name="skip">এড়িয়ে যান</string>
<string name="save">সংরক্ষণ করুন</string>
<string name="passcode_setup">লগ ইন পিন সেট করুন</string>
<string name="reenter_passcode">পিন পুনরায় লিখুন</string>
Expand All @@ -320,7 +320,7 @@
<string name="logout">লগ আউট করুন</string>
<string name="share_msg">এখানে স্ব পরিষেবা অ্যাপ্লিকেশনটি ডাউনলোড করুন: https://play.google.com/store/apps/details?id=</string>
<string name="choose">আবেদন নির্বাচন করুন</string>
<string name="not_available">দ্য</string>
<string name="not_available">পাওয়া যায় না</string>
<string name="upload_qr_code">QR জমা দিন</string>
<string name="select_region_qr">QR কোড সঙ্গে অঞ্চল নির্বাচন করুন</string>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package org.mifos.mobile.repositories

import CoroutineTestRule
import app.cash.turbine.test
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.client.ClientAccounts
import org.mifos.mobile.util.checkForUnsuccessfulOperation
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
Expand All @@ -36,31 +39,27 @@ class AccountsRepositoryImpTest {
}

@Test
fun loadAccounts_Success() = runBlocking {
fun loadAccounts_Success() = runTest {
val mockAccountType = "savings"
val mockClientAccounts = mock(ClientAccounts::class.java)
`when`(dataManager.getAccounts(mockAccountType)).thenReturn((mockClientAccounts))

val resultFlow = accountsRepositoryImp.loadAccounts(mockAccountType)
val resultAccounts = resultFlow.first()

assert(resultAccounts == mockClientAccounts)
resultFlow.test {
assertEquals(mockClientAccounts, awaitItem())
cancelAndIgnoreRemainingEvents()
}
}

@Test
fun loadAccounts_Error() = runBlocking {
@Test(expected = Exception::class)
fun loadAccounts_Error() = runTest {
val mockAccountType = "savings"
val mockError = IOException("Network error")
`when`(dataManager.getAccounts(mockAccountType)).thenThrow(mockError)

val resultFlow = accountsRepositoryImp.loadAccounts(mockAccountType)
var isErrorThrown = false
try {
resultFlow.first()
} catch (e: Exception) {
isErrorThrown = true
assert(e is IOException)
`when`(dataManager.getAccounts(mockAccountType))
.thenThrow(Exception("Error occurred"))
val result = accountsRepositoryImp.loadAccounts(mockAccountType)
result.test {
assert(Throwable("Error occurred") == awaitError())
}
assert(isErrorThrown)
}

}
Loading

0 comments on commit a3030e8

Please sign in to comment.