Skip to content

Commit 3b74add

Browse files
committed
Add UNKNOWN loan status fallback and check for the REJECTED loan status type explicitly
1 parent 81275fe commit 3b74add

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

feature/loan/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,4 +482,5 @@
482482
<string name="feature_loan_closed_written_off">Closed (Written Off)</string>
483483
<string name="feature_loan_closed_rescheduled">Closed (Rescheduled)</string>
484484
<string name="feature_loan_rejected">Rejected</string>
485+
<string name="feature_loan_unknown">Unknown</string>">
485486
</resources>

feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidclient.feature.loan.generated.resources.feature_loan_closed_resche
1818
import androidclient.feature.loan.generated.resources.feature_loan_closed_written_off
1919
import androidclient.feature.loan.generated.resources.feature_loan_pending_approval
2020
import androidclient.feature.loan.generated.resources.feature_loan_rejected
21+
import androidclient.feature.loan.generated.resources.feature_loan_unknown
2122
import androidclient.feature.loan.generated.resources.feature_loan_withdrawn_by_applicant
2223
import androidx.compose.ui.graphics.Color
2324
import com.mifos.core.designsystem.theme.AppColors
@@ -64,18 +65,23 @@ enum class LoanStatus(
6465
Res.string.feature_loan_rejected,
6566
AppColors.loanRejectedStatus,
6667
),
68+
UNKNOWN(
69+
Res.string.feature_loan_unknown,
70+
AppColors.loanUnknownStatus,
71+
),
6772
}
6873

6974
fun LoanStatusEntity.getLoanStatus(): LoanStatus {
7075
return when {
7176
this.code == "loanStatusType.withdrawn.by.client" -> LoanStatus.WITHDRAWN_BY_APPLICANT
77+
this.code == "loanStatusType.rejected" -> LoanStatus.REJECTED
7278
this.overpaid == true -> LoanStatus.CLOSED_OVERPAID
7379
this.closedWrittenOff == true -> LoanStatus.CLOSED_WRITTEN_OFF
7480
this.closedRescheduled == true -> LoanStatus.CLOSED_RESCHEDULED
7581
this.closedObligationsMet == true -> LoanStatus.CLOSED_OBLIGATIONS_MET
7682
this.active == true -> LoanStatus.ACTIVE
7783
this.waitingForDisbursal == true -> LoanStatus.APPROVED
7884
this.pendingApproval == true -> LoanStatus.PENDING_APPROVAL
79-
else -> LoanStatus.REJECTED
85+
else -> LoanStatus.UNKNOWN
8086
}
8187
}

0 commit comments

Comments
 (0)