Skip to content

Commit

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

* Java to Kotlin

* Java to Kotlin
  • Loading branch information
Aditya-gupta99 committed Jul 15, 2023
1 parent ca30148 commit b87fd8a
Show file tree
Hide file tree
Showing 109 changed files with 1,779 additions and 6,754 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class DatabaseHelperLoan @Inject constructor() {
//Setting ActualDisbursement in Table
val actualDisbursementDate = ActualDisbursementDate(
loanWithAssociations.id,
loanWithAssociations.timeline.actualDisbursementDate[0],
loanWithAssociations.timeline.actualDisbursementDate[1],
loanWithAssociations.timeline.actualDisbursementDate[2]
loanWithAssociations.timeline.actualDisbursementDate?.get(0),
loanWithAssociations.timeline.actualDisbursementDate?.get(1),
loanWithAssociations.timeline.actualDisbursementDate?.get(2)
)
timeline.actualDisburseDate = actualDisbursementDate
loanWithAssociations.timeline = timeline
Expand Down Expand Up @@ -69,10 +69,10 @@ class DatabaseHelperLoan @Inject constructor() {
if (loanWithAssociations != null) {
loanWithAssociations.timeline.actualDisbursementDate = listOf(
loanWithAssociations.timeline.actualDisburseDate
.year, loanWithAssociations.timeline
.actualDisburseDate.month,
?.year, loanWithAssociations.timeline
.actualDisburseDate?.month,
loanWithAssociations
.timeline.actualDisburseDate.date
.timeline.actualDisburseDate?.date
)
}
Observable.just(loanWithAssociations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ class LoanAccountsListAdapter(

val loanAccount = loanAccountList[i]

if (loanAccount.status.active) {
if (loanAccount.status?.active == true) {
binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(context, R.color.loan_status_disbursed)
)
} else if (loanAccount.status.waitingForDisbursal) {
} else if (loanAccount.status?.waitingForDisbursal == true) {
binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(context, R.color.status_approved)
)
} else if (loanAccount.status.pendingApproval) {
} else if (loanAccount.status?.pendingApproval == true) {
binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(
context,
R.color.status_submitted_and_pending_approval
)
)
} else if (loanAccount.status.active && loanAccount.inArrears) {
} else if (loanAccount.status?.active == true && loanAccount.inArrears == true) {
binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(context, R.color.red)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class LoanRepaymentScheduleAdapter(
}

val period = periodList[i]
viewHolder.binding.tvRepaymentDueDate.text = getDateAsString(period.dueDate)
viewHolder.binding.tvRepaymentDueDate.text = period.dueDate?.let { getDateAsString(it) }
viewHolder.binding.tvRepaymentAmountDue.text = period.totalDueForPeriod.toString()
viewHolder.binding.tvRepaymentAmountPaid.text = period.totalPaidForPeriod.toString()

when {
period.complete != null && period.complete -> {
period.complete != null && period.complete!! -> {
viewHolder.binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(
context,
Expand All @@ -67,7 +67,7 @@ class LoanRepaymentScheduleAdapter(
)
}

period.totalOverdue != null && period.totalOverdue > 0 -> {
period.totalOverdue != null && period.totalOverdue!! > 0 -> {
viewHolder.binding.viewStatusIndicator.setBackgroundColor(
ContextCompat.getColor(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,41 @@ class LoanTransactionAdapter(

init {
for (transaction in transactionList) {
val parent = Parent(
transaction.date,
transaction.type,
transaction.amount
)
val child = Child(
transaction.id,
transaction.officeName,
transaction.principalPortion,
transaction.interestPortion,
transaction.feeChargesPortion,
transaction.penaltyChargesPortion
)
parents.add(parent)
children.add(child)
val parent = transaction.type?.let {
transaction.amount?.let { it1 ->
Parent(
transaction.date,
it,
it1
)
}
}
val child = transaction.id?.let {
transaction.officeName?.let { it1 ->
transaction.principalPortion?.let { it2 ->
transaction.interestPortion?.let { it3 ->
transaction.feeChargesPortion?.let { it4 ->
transaction.penaltyChargesPortion?.let { it5 ->
Child(
it,
it1,
it2,
it3,
it4,
it5
)
}
}
}
}
}
}
if (parent != null) {
parents.add(parent)
}
if (child != null) {
children.add(child)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ class SyncLoanRepaymentAdapter @Inject constructor() :

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val loanRepaymentRequest = loanRepaymentRequests[position]
val paymentTypeName = getPaymentTypeName(
loanRepaymentRequest.paymentTypeId.toInt(), mPaymentTypeOptions
)
val paymentTypeName = loanRepaymentRequest.paymentTypeId?.let {
getPaymentTypeName(
it.toInt(), mPaymentTypeOptions
)
}
holder.binding.tvLoanId.text = loanRepaymentRequest.loanId.toString()
holder.binding.tvAccountNumber.text = loanRepaymentRequest.accountNumber
if (mPaymentTypeOptions.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class SyncCenterDialogPresenter @Inject constructor(
*/
private fun checkNetworkConnectionAndSyncLoanAndLoanRepayment() {
if (mvpView?.isOnline == true) {
syncLoanAndLoanRepayment(mLoanAccountList[mLoanAndRepaymentSyncIndex].id)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let { syncLoanAndLoanRepayment(it) }
} else {
mvpView?.showNetworkIsNotAvailable()
mvpView?.dismissDialog()
Expand All @@ -245,7 +245,11 @@ class SyncCenterDialogPresenter @Inject constructor(
*/
private fun checkNetworkConnectionAndSyncMemberLoanAndMemberLoanRepayment() {
if (mvpView?.isOnline == true) {
syncMemberLoanAndMemberLoanRepayment(mMemberLoanAccountsList[mMemberLoanSyncIndex].id)
mMemberLoanAccountsList[mMemberLoanSyncIndex].id?.let {
syncMemberLoanAndMemberLoanRepayment(
it
)
}
} else {
mvpView?.showNetworkIsNotAvailable()
mvpView?.dismissDialog()
Expand Down Expand Up @@ -626,9 +630,11 @@ class SyncCenterDialogPresenter @Inject constructor(
private fun checkAccountsSyncStatusAndSyncGroupAccounts() {
if (!mLoanAccountList.isEmpty() && !mLoanAccountSyncStatus) {
//Sync the Active Loan and LoanRepayment
syncGroupLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncGroupLoanAndLoanRepayment(
it
)
}
} else if (!mSavingsAccountList.isEmpty()) {
//Sync the Active Savings Account
syncGroupSavingsAccountAndTemplate(
Expand All @@ -649,9 +655,11 @@ class SyncCenterDialogPresenter @Inject constructor(
private fun checkAccountsSyncStatusAndSyncClientAccounts() {
if (!mLoanAccountList.isEmpty() && !mLoanAccountSyncStatus) {
//Sync the Active Loan and LoanRepayment
syncClientLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncClientLoanAndLoanRepayment(
it
)
}
} else if (!mSavingsAccountList.isEmpty()) {
//Sync the Active Savings Account
syncClientSavingsAccountAndTemplate(
Expand All @@ -671,7 +679,7 @@ class SyncCenterDialogPresenter @Inject constructor(
*/
private fun syncGroup(group: Group) {
checkViewAttached()
group.centerId = mCenterList.get(mCenterSyncIndex).id
group.centerId = mCenterList[mCenterSyncIndex].id
group.isSync = true
mSubscriptions.add(
mDataManagerGroups.syncGroupInDatabase(group)
Expand Down Expand Up @@ -754,9 +762,11 @@ class SyncCenterDialogPresenter @Inject constructor(
override fun onNext(loanAndLoanRepayment: LoanAndLoanRepayment) {
mLoanAndRepaymentSyncIndex += 1
if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size) {
syncGroupLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncGroupLoanAndLoanRepayment(
it
)
}
} else {
setLoanAccountSyncStatusTrue()
checkAccountsSyncStatusAndSyncGroupAccounts()
Expand Down Expand Up @@ -788,9 +798,11 @@ class SyncCenterDialogPresenter @Inject constructor(
override fun onNext(loanAndLoanRepayment: LoanAndLoanRepayment) {
mLoanAndRepaymentSyncIndex += 1
if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size) {
syncClientLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncClientLoanAndLoanRepayment(
it
)
}
} else {
setLoanAccountSyncStatusTrue()
checkAccountsSyncStatusAndSyncClientAccounts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SyncClientsDialogPresenter @Inject constructor(

fun checkNetworkConnectionAndSyncLoanAndLoanRepayment() {
if (mvpView?.isOnline == true) {
syncLoanAndLoanRepayment(mLoanAccountList[mLoanAndRepaymentSyncIndex].id)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let { syncLoanAndLoanRepayment(it) }
} else {
mvpView?.showNetworkIsNotAvailable()
mvpView?.dismissDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SyncGroupsDialogPresenter @Inject constructor(
*/
private fun checkNetworkConnectionAndSyncLoanAndLoanRepayment() {
if (mvpView?.isOnline == true) {
syncLoanAndLoanRepayment(mLoanAccountList[mLoanAndRepaymentSyncIndex].id)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let { syncLoanAndLoanRepayment(it) }
} else {
mvpView?.showNetworkIsNotAvailable()
mvpView?.dismissDialog()
Expand Down Expand Up @@ -376,9 +376,11 @@ class SyncGroupsDialogPresenter @Inject constructor(
private fun checkAccountsSyncStatusAndSyncClientAccounts() {
if (mLoanAccountList.isNotEmpty() && !mLoanAccountSyncStatus) {
//Sync the Active Loan and LoanRepayment
syncClientLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncClientLoanAndLoanRepayment(
it
)
}
} else if (mSavingsAccountList.isNotEmpty()) {
//Sync the Active Savings Account
syncClientSavingsAccountAndTemplate(
Expand Down Expand Up @@ -452,9 +454,11 @@ class SyncGroupsDialogPresenter @Inject constructor(
override fun onNext(loanAndLoanRepayment: LoanAndLoanRepayment) {
mLoanAndRepaymentSyncIndex += 1
if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size) {
syncClientLoanAndLoanRepayment(
mLoanAccountList[mLoanAndRepaymentSyncIndex].id
)
mLoanAccountList[mLoanAndRepaymentSyncIndex].id?.let {
syncClientLoanAndLoanRepayment(
it
)
}
} else {
setLoanAccountSyncStatusTrue()
checkAccountsSyncStatusAndSyncClientAccounts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ class SyncLoanRepaymentTransactionFragment : MifosBaseFragment(),
}

override fun showPaymentSubmittedSuccessfully() {
mSyncLoanRepaymentTransactionPresenter
.deleteAndUpdateLoanRepayments(
mLoanRepaymentRequests
!![mClientSyncIndex].loanId
)
mLoanRepaymentRequests?.get(mClientSyncIndex)?.loanId?.let {
mSyncLoanRepaymentTransactionPresenter
.deleteAndUpdateLoanRepayments(
it
)
}
}

override fun showPaymentFailed(errorMessage: String) {
Expand Down Expand Up @@ -224,11 +225,12 @@ class SyncLoanRepaymentTransactionFragment : MifosBaseFragment(),

private fun syncGroupPayload() {
for (i in mLoanRepaymentRequests!!.indices) {
if (mLoanRepaymentRequests!![i].errorMessage == null) {
mSyncLoanRepaymentTransactionPresenter.syncLoanRepayment(
mLoanRepaymentRequests!![i]
.loanId, mLoanRepaymentRequests!![i]
)
if (mLoanRepaymentRequests?.get(i)?.errorMessage == null) {
mLoanRepaymentRequests?.get(i)?.loanId?.let {
mSyncLoanRepaymentTransactionPresenter.syncLoanRepayment(
it, mLoanRepaymentRequests?.get(i)
)
}
mClientSyncIndex = i
break
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ class OfflineSyncLoanRepayment : Job() {
fun syncGroupPayload() {
for (i in mClientSyncIndex until mLoanRepaymentRequests.size) {
if (mLoanRepaymentRequests[i].errorMessage == null) {
syncLoanRepayment(
mLoanRepaymentRequests
.get(i)
.loanId, mLoanRepaymentRequests[i]
)
mLoanRepaymentRequests[i]
.loanId?.let {
syncLoanRepayment(
it, mLoanRepaymentRequests[i]
)
}
mClientSyncIndex = i
break
}
Expand Down Expand Up @@ -122,10 +123,11 @@ class OfflineSyncLoanRepayment : Job() {
}

fun showPaymentSubmittedSuccessfully() {
deleteAndUpdateLoanRepayments(
mLoanRepaymentRequests
.get(mClientSyncIndex).loanId
)
mLoanRepaymentRequests[mClientSyncIndex].loanId?.let {
deleteAndUpdateLoanRepayments(
it
)
}
}

private fun deleteAndUpdateLoanRepayments(loanId: Int) {
Expand Down
Loading

0 comments on commit b87fd8a

Please sign in to comment.