Skip to content

Commit

Permalink
Spotless detekt on Core:Database (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
kapmaurya authored Dec 7, 2024
1 parent b050f98 commit 8f1fb9a
Show file tree
Hide file tree
Showing 294 changed files with 3,071 additions and 914 deletions.
9 changes: 9 additions & 0 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.hilt)
Expand Down
9 changes: 9 additions & 0 deletions core/database/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Mifos Initiative
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
See https://github.com/openMF/android-client/blob/master/LICENSE.md
-->
<manifest>

</manifest>
11 changes: 8 additions & 3 deletions core/database/src/main/java/com/mifos/core/data/CenterPayload.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data
Expand Down Expand Up @@ -44,5 +49,5 @@ data class CenterPayload(
var active: Boolean = false,

@Column
var activationDate: String? = null
) : MifosBaseModel(), Parcelable
var activationDate: String? = null,
) : MifosBaseModel(), Parcelable
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data

/**
Expand All @@ -15,4 +24,4 @@ class ChargesPayload {
var locale: String? = null
var dueDate: String? = null
var dateFormat: String? = null
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data
Expand Down Expand Up @@ -42,5 +47,5 @@ data class GroupLoanPayload(
var submittedOnDate: String? = null,
var transactionProcessingStrategyId: Int? = null,
var loanPurposeId: Int? = null,
var linkAccountId: Int? = null
) : Parcelable
var linkAccountId: Int? = null,
) : Parcelable
11 changes: 8 additions & 3 deletions core/database/src/main/java/com/mifos/core/data/LoansPayload.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data
Expand Down Expand Up @@ -46,5 +51,5 @@ class LoansPayload(
var loanOfficerId: Int? = null,
var fundId: Int? = null,
var linkAccountId: Int? = null,
var dataTables: ArrayList<DataTablePayload>? = null
) : Parcelable
var dataTables: ArrayList<DataTablePayload>? = null,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data

/**
Expand All @@ -23,4 +32,4 @@ class SavingsPayload {
var nominalAnnualInterestRateOverdraft: String? = null
var overdraftLimit: String? = null
var minOverdraftForInterestCalculation: String? = null
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.database

import com.raizlabs.android.dbflow.annotation.Database
Expand All @@ -10,6 +19,6 @@ object MifosDatabase {
// database name will be Mifos.db
const val NAME = "Mifos"

//Always Increase the Version Number
// Always Increase the Version Number
const val VERSION = 2
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.database

import com.mifos.core.objects.accounts.loan.LoanAccount
Expand Down Expand Up @@ -36,4 +45,4 @@ class MigrationVersion2 {
addColumn(SQLiteType.INTEGER, "centerDate_year")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.databasehelper

import android.os.AsyncTask
Expand Down Expand Up @@ -44,7 +53,7 @@ class DatabaseHelperCenter @Inject constructor() {
*
* @return List Of Centers
*/
//TODO Implement Observable Transaction to load Center List
// TODO Implement Observable Transaction to load Center List
fun readAllCenters(): Observable<Page<Center>> {
return Observable.create<Page<Center>> { subscriber ->
val centerPage = Page<Center>()
Expand Down Expand Up @@ -103,10 +112,11 @@ class DatabaseHelperCenter @Inject constructor() {
center.activationDate[1]?.let { it2 ->
center.activationDate[2]?.let { it3 ->
CenterDate(
it.toLong(), 0,
it.toLong(),
0,
it1,
it2,
it3
it3,
)
}
}
Expand Down Expand Up @@ -136,7 +146,7 @@ class DatabaseHelperCenter @Inject constructor() {
}

fun updateDatabaseCenterPayload(
centerPayload: CenterPayload
centerPayload: CenterPayload,
): Observable<CenterPayload> {
return Observable.defer {
centerPayload.update()
Expand All @@ -153,7 +163,7 @@ class DatabaseHelperCenter @Inject constructor() {
*/
fun saveCenterAccounts(
centerAccounts: CenterAccounts,
centerId: Int
centerId: Int,
): Observable<CenterAccounts> {
return Observable.defer {
val loanAccounts = centerAccounts.loanAccounts
Expand All @@ -174,4 +184,4 @@ class DatabaseHelperCenter @Inject constructor() {
Observable.just(centerAccounts)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.databasehelper

import android.os.AsyncTask
Expand Down Expand Up @@ -25,23 +34,26 @@ class DatabaseHelperCharge @Inject constructor() {
*/
fun saveClientCharges(
chargesPage: Page<Charges>,
clientId: Int
clientId: Int,
): Observable<Void>? {
AsyncTask.THREAD_POOL_EXECUTOR.execute(Runnable {
for (charges: Charges in chargesPage.pageItems) {
charges.clientId = clientId
val clientDate = charges.id?.toLong()?.let {
ClientDate(
0, it,
charges.dueDate[2],
charges.dueDate[1],
charges.dueDate[0]
)
AsyncTask.THREAD_POOL_EXECUTOR.execute(
Runnable {
for (charges: Charges in chargesPage.pageItems) {
charges.clientId = clientId
val clientDate = charges.id?.toLong()?.let {
ClientDate(
0,
it,
charges.dueDate[2],
charges.dueDate[1],
charges.dueDate[0],
)
}
charges.chargeDueDate = clientDate
charges.save()
}
charges.chargeDueDate = clientDate
charges.save()
}
})
},
)
return null
}

Expand All @@ -53,23 +65,23 @@ class DatabaseHelperCharge @Inject constructor() {
* @return Page of Charges
*/
fun readClientCharges(clientId: Int): Observable<Page<Charges>> {
return Observable.create<Page<Charges>> { subscriber -> //Loading All charges from Charges_Table as reference to client id
return Observable.create<Page<Charges>> { subscriber -> // Loading All charges from Charges_Table as reference to client id
val chargesList = SQLite.select()
.from(Charges::class.java)
.where(Charges_Table.clientId.eq(clientId))
.queryList()

//Setting the Charge Due Date
// Setting the Charge Due Date
for (i in chargesList.indices) {
chargesList[i].dueDate = listOf(
chargesList[i].chargeDueDate!!.year,
chargesList[i].chargeDueDate!!.month,
chargesList[i].chargeDueDate!!.day
chargesList[i].chargeDueDate!!.day,
)
}
val chargePage = Page<Charges>()
chargePage.pageItems = chargesList
subscriber.onNext(chargePage)
}
}
}
}
Loading

0 comments on commit 8f1fb9a

Please sign in to comment.