Skip to content

Commit

Permalink
fix openMF#1724 Last Transaction details fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rutvik-panchal committed Feb 17, 2021
1 parent 7ed4f22 commit df41be9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.mifos.mobile.models.accounts.savings
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import org.mifos.mobile.models.client.DepositType
import org.mifos.mobile.utils.DateHelper
import java.util.*

/**
Expand Down Expand Up @@ -77,5 +78,15 @@ data class SavingsWithAssociations(
this.nominalAnnualInterestRate = nominalAnnualInterestRate
}

fun getLastTransaction() : Transactions? {
lastActiveTransactionDate?.let {
for (transaction in transactions) {
if (DateHelper.equals(transaction.date, it)) {
return transaction
}
}
}
return null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class SavingAccountsDetailFragment : BaseFragment(), SavingAccountsDetailView {
if (savingsWithAssociations.transactions.isNotEmpty()) {
tvLastTransaction?.text = getString(R.string.string_and_double,
currencySymbol,
savingsWithAssociations.transactions[0].amount)
savingsWithAssociations.getLastTransaction()?.amount)
tvMadeOnTransaction?.text = DateHelper.getDateAsString(
savingsWithAssociations.lastActiveTransactionDate)
savingsWithAssociations.getLastTransaction()?.date)
} else {
tvLastTransaction?.setText(R.string.no_transaction)
tvMadeOnTransaction?.visibility = View.GONE
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/mifos/mobile/utils/DateHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,8 @@ object DateHelper {
val sdf = SimpleDateFormat("HH:mm a dd MMM yyyy")
return sdf.format(timeInMillis?.let { Date(it) })
}

fun equals(dateOne: List<Int>, dateTwo: List<Int>): Boolean {
return dateOne[0] == dateTwo[0] && dateOne[1] == dateTwo[1] && dateOne[2] == dateTwo[2]
}
}

0 comments on commit df41be9

Please sign in to comment.