Skip to content

Commit

Permalink
Fixes #1968 : Java to Kotlin Migration (#1995)
Browse files Browse the repository at this point in the history
* Java to kotlin

* Changed BASEURL and Java to kotlin conversion

* Java to Kotlin
  • Loading branch information
Aditya-gupta99 authored Jul 13, 2023
1 parent c0ac82f commit ca30148
Show file tree
Hide file tree
Showing 114 changed files with 1,583 additions and 8,381 deletions.
2 changes: 1 addition & 1 deletion mifosng-android/src/main/java/com/mifos/api/BaseUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BaseUrl {
// "/" in the last of the base url always
companion object {
const val PROTOCOL_HTTPS = "https://"
const val API_ENDPOINT = "demo.mifos.io"
const val API_ENDPOINT = "demo.mifos.community"
const val API_PATH = "/fineract-provider/api/v1/"
const val PORT = "80"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ class DatabaseHelperLoan @Inject constructor() {
): Observable<LoanRepaymentTemplate> {
return Observable.defer {
loanRepaymentTemplate.loanId = loanId
for (paymentTypeOption: PaymentTypeOption in loanRepaymentTemplate
.paymentTypeOptions) {
for (paymentTypeOption: PaymentTypeOption in loanRepaymentTemplate.paymentTypeOptions!!) {
paymentTypeOption.save()
}
loanRepaymentTemplate.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
var disbursementDate: String? = null
private val mListener: OnDialogFragmentInteractionListener? = null
private var mfDatePicker: DialogFragment? = null
private var productId = 0
private var productId : Int? = 0
private var groupId = 0
private var loanPurposeId = 0
private var loanTermFrequency = 0
private var loanTermFrequencyType = 0
private var loanPurposeId : Int? =null
private var loanTermFrequency : Int? = null
private var loanTermFrequencyType : Int ? = null
private var termFrequency: Int? = null
private var repaymentEvery: Int? = null
private var transactionProcessingStrategyId = 0
private var amortizationTypeId = 0
private var interestCalculationPeriodTypeId = 0
private var fundId: Int = 0
private var loanOfficerId = 0
private var interestTypeMethodId = 0
private var transactionProcessingStrategyId : Int? = null
private var amortizationTypeId : Int ? = null
private var interestCalculationPeriodTypeId : Int? =null
private var fundId: Int ? = null
private var loanOfficerId : Int ? = null
private var interestTypeMethodId : Int ? = null
private var repaymentFrequencyNthDayType: Int? = null
private var repaymentFrequencyDayOfWeek: Int? = null
private var interestRatePerPeriod: Double? = null
Expand Down Expand Up @@ -96,10 +96,8 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
private var fundOptionsAdapter: ArrayAdapter<String>? = null
private var mGroupLoanTemplate: GroupLoanTemplate? = null
private var mLoanProducts: List<LoanProducts>? = null
var mRepaymentFrequencyNthDayTypeOptions: List<RepaymentFrequencyNthDayTypeOptions> =
ArrayList()
var mRepaymentFrequencyDaysOfWeekTypeOptions: List<RepaymentFrequencyDaysOfWeekTypeOptions> =
ArrayList()
var mRepaymentFrequencyNthDayTypeOptions: List<RepaymentFrequencyNthDayTypeOptions>? = null
var mRepaymentFrequencyDaysOfWeekTypeOptions: List<RepaymentFrequencyDaysOfWeekTypeOptions>? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -292,7 +290,7 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
}

private fun inflateLoanPurposeSpinner() {
mGroupLoanAccountPresenter.loadGroupLoansAccountTemplate(groupId, productId)
productId?.let { mGroupLoanAccountPresenter.loadGroupLoansAccountTemplate(groupId, it) }
}

private fun initiateLoanCreation(loansPayload: GroupLoanPayload) {
Expand Down Expand Up @@ -379,16 +377,16 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
fundOptions.addAll(mGroupLoanAccountPresenter.filterFunds(groupLoanTemplate?.fundOptions))
fundOptionsAdapter?.notifyDataSetChanged()
mListRepaymentFrequencyNthDayTypeOptions.clear()
mRepaymentFrequencyNthDayTypeOptions = mGroupLoanTemplate!!
.repaymentFrequencyNthDayTypeOptions
for (options in mRepaymentFrequencyNthDayTypeOptions) {
mListRepaymentFrequencyNthDayTypeOptions.add(options.value)
mRepaymentFrequencyNthDayTypeOptions = mGroupLoanTemplate
?.repaymentFrequencyNthDayTypeOptions
for (options in mRepaymentFrequencyNthDayTypeOptions!!) {
options.value?.let { mListRepaymentFrequencyNthDayTypeOptions.add(it) }
}
mListRepaymentFrequencyDayOfWeekTypeOptions.clear()
mRepaymentFrequencyDaysOfWeekTypeOptions = mGroupLoanTemplate!!
.repaymentFrequencyDaysOfWeekTypeOptions
for (options in mRepaymentFrequencyDaysOfWeekTypeOptions) {
mListRepaymentFrequencyDayOfWeekTypeOptions.add(options.value)
for (options in mRepaymentFrequencyDaysOfWeekTypeOptions!!) {
options.value?.let { mListRepaymentFrequencyDayOfWeekTypeOptions.add(it) }
}
showDefaultValues()
}
Expand Down Expand Up @@ -419,23 +417,22 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
when (parent.id) {
R.id.sp_lproduct -> {
productId = mLoanProducts!![position].id
productId = mLoanProducts?.get(position)?.id
inflateLoanPurposeSpinner()
}

R.id.sp_amortization -> amortizationTypeId = mGroupLoanTemplate
?.amortizationTypeOptions!![position].id
?.amortizationTypeOptions?.get(position)?.id

R.id.sp_interestcalculationperiod -> interestCalculationPeriodTypeId =
mGroupLoanTemplate
?.interestCalculationPeriodTypeOptions!![position].id
mGroupLoanTemplate?.interestCalculationPeriodTypeOptions?.get(position)?.id

R.id.sp_repaymentstrategy -> transactionProcessingStrategyId = mGroupLoanTemplate
?.transactionProcessingStrategyOptions!![position].id
?.transactionProcessingStrategyOptions?.get(position)?.id

R.id.sp_payment_periods -> {
loanTermFrequency = mGroupLoanTemplate
?.termFrequencyTypeOptions!![position].id
?.termFrequencyTypeOptions?.get(position)?.id
if (loanTermFrequency == 2) {
// Show and inflate Nth day and week spinners
showHideRepaidMonthSpinners(View.VISIBLE)
Expand All @@ -446,21 +443,21 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
}

R.id.sp_repayment_freq_nth_day -> repaymentFrequencyNthDayType = mGroupLoanTemplate
?.repaymentFrequencyNthDayTypeOptions!![position].id
?.repaymentFrequencyNthDayTypeOptions?.get(position)?.id

R.id.sp_repayment_freq_day_of_week -> repaymentFrequencyDayOfWeek = mGroupLoanTemplate
?.repaymentFrequencyDaysOfWeekTypeOptions!![position].id
?.repaymentFrequencyDaysOfWeekTypeOptions?.get(position)?.id

R.id.sp_loan_purpose -> loanPurposeId =
mGroupLoanTemplate!!.loanPurposeOptions[position].id
mGroupLoanTemplate?.loanPurposeOptions?.get(position)?.id

R.id.sp_interest_type -> interestTypeMethodId =
mGroupLoanTemplate!!.interestTypeOptions[position].id
mGroupLoanTemplate?.interestTypeOptions?.get(position)?.id

R.id.sp_loan_officer -> loanOfficerId =
mGroupLoanTemplate!!.loanOfficerOptions[position].id
mGroupLoanTemplate?.loanOfficerOptions?.get(position)?.id

R.id.sp_fund -> fundId = mGroupLoanTemplate!!.fundOptions[position].id
R.id.sp_fund -> fundId = mGroupLoanTemplate?.fundOptions?.get(position)?.id
}
}

Expand All @@ -472,7 +469,7 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene

private fun showDefaultValues() {
interestRatePerPeriod = mGroupLoanTemplate?.interestRatePerPeriod
loanTermFrequencyType = mGroupLoanTemplate!!.interestRateFrequencyType.id
loanTermFrequencyType = mGroupLoanTemplate?.interestRateFrequencyType?.id
termFrequency = mGroupLoanTemplate?.termFrequency
binding.etPrincipal.setText(mGroupLoanTemplate?.principal.toString())
binding.etNumberofrepayments.setText(mGroupLoanTemplate?.numberOfRepayments.toString())
Expand All @@ -484,8 +481,8 @@ class GroupLoanAccountFragment : ProgressableDialogFragment(), OnDatePickListene
binding.etRepaidevery.setText(repaymentEvery.toString())
}
if (mGroupLoanTemplate?.fundId != null) {
fundId = mGroupLoanTemplate!!.fundId
binding.spFund.setSelection(mGroupLoanTemplate!!.getFundNameFromId(fundId))
fundId = mGroupLoanTemplate?.fundId
binding.spFund.setSelection(mGroupLoanTemplate?.fundId?:0)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,23 @@ class GroupLoanAccountPresenter @Inject constructor(private val mDataManager: Da
fun filterAmortizations(amortizationTypeOptions: List<AmortizationTypeOptions>?): List<String> {
val amortizationNameList = ArrayList<String>()
Observable.from(amortizationTypeOptions)
.subscribe { amortizationTypeOptions -> amortizationNameList.add(amortizationTypeOptions.value) }
.subscribe { amortizationTypeOptions -> amortizationTypeOptions.value?.let {
amortizationNameList.add(
it
)
} }
return amortizationNameList
}

fun filterInterestCalculationPeriods(interestCalculationPeriodType: List<InterestCalculationPeriodType>?): List<String> {
val interestCalculationPeriodNameList = ArrayList<String>()
Observable.from(interestCalculationPeriodType)
.subscribe { interestCalculationPeriodType ->
interestCalculationPeriodNameList.add(
interestCalculationPeriodType.value)
interestCalculationPeriodType.value?.let {
interestCalculationPeriodNameList.add(
it
)
}
}
return interestCalculationPeriodNameList
}
Expand All @@ -122,8 +129,11 @@ class GroupLoanAccountPresenter @Inject constructor(private val mDataManager: Da
val transactionProcessingStrategyNameList = ArrayList<String>()
Observable.from(transactionProcessingStrategyOptions)
.subscribe { transactionProcessingStrategyOptions ->
transactionProcessingStrategyNameList.add(
transactionProcessingStrategyOptions.name)
transactionProcessingStrategyOptions.name?.let {
transactionProcessingStrategyNameList.add(
it
)
}
}
return transactionProcessingStrategyNameList
}
Expand All @@ -138,35 +148,51 @@ class GroupLoanAccountPresenter @Inject constructor(private val mDataManager: Da
fun filterTermFrequencyTypes(termFrequencyTypeOptions: List<TermFrequencyTypeOptions>?): List<String> {
val termFrequencyNameList = ArrayList<String>()
Observable.from(termFrequencyTypeOptions)
.subscribe { termFrequencyTypeOptions -> termFrequencyNameList.add(termFrequencyTypeOptions.value) }
.subscribe { termFrequencyTypeOptions -> termFrequencyTypeOptions.value?.let {
termFrequencyNameList.add(
it
)
} }
return termFrequencyNameList
}

fun filterLoanPurposeTypes(loanPurposeOptions: List<LoanPurposeOptions>?): List<String> {
val loanPurposeNameList = ArrayList<String>()
Observable.from(loanPurposeOptions)
.subscribe { loanPurposeOptions -> loanPurposeNameList.add(loanPurposeOptions.name) }
.subscribe { loanPurposeOptions -> loanPurposeOptions.name?.let {
loanPurposeNameList.add(
it
)
} }
return loanPurposeNameList
}

fun filterInterestTypeOptions(interestTypeOptions: List<InterestTypeOptions>?): List<String> {
val interestTypeNameList = ArrayList<String>()
Observable.from(interestTypeOptions)
.subscribe { interestTypeOptions -> interestTypeNameList.add(interestTypeOptions.value) }
.subscribe { interestTypeOptions -> interestTypeOptions.value?.let {
interestTypeNameList.add(
it
)
} }
return interestTypeNameList
}

fun filterLoanOfficers(loanOfficerOptions: List<LoanOfficerOptions>?): List<String> {
val loanOfficerNameList = ArrayList<String>()
Observable.from(loanOfficerOptions)
.subscribe { loanOfficerOptions -> loanOfficerNameList.add(loanOfficerOptions.displayName) }
.subscribe { loanOfficerOptions -> loanOfficerOptions.displayName?.let {
loanOfficerNameList.add(
it
)
} }
return loanOfficerNameList
}

fun filterFunds(fundOptions: List<FundOptions>?): List<String> {
val fundNameList = ArrayList<String>()
Observable.from(fundOptions)
.subscribe { fundOptions -> fundNameList.add(fundOptions.name) }
.subscribe { fundOptions -> fundOptions.name?.let { fundNameList.add(it) } }
return fundNameList
}

Expand Down
Loading

0 comments on commit ca30148

Please sign in to comment.