Skip to content

Commit 28f9bd5

Browse files
Fix invoice api (#1797)
* Redesign requeset screen UI * fix MissingKoinDefinitionException * removed comments and fixed share qr code bug * fix: Invoice APIs
1 parent fac59da commit 28f9bd5

File tree

34 files changed

+879
-554
lines changed

34 files changed

+879
-554
lines changed

core/data/src/main/java/org/mifospay/core/data/domain/usecase/invoice/FetchInvoice.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package org.mifospay.core.data.domain.usecase.invoice
1111

1212
import android.net.Uri
1313
import android.util.Log
14-
import com.mifospay.core.model.entity.Invoice
14+
import com.mifospay.core.model.entity.invoice.Invoice
1515
import org.mifospay.core.data.base.UseCase
1616
import org.mifospay.core.data.fineract.repository.FineractRepository
1717
import org.mifospay.core.data.util.Constants
@@ -27,13 +27,12 @@ class FetchInvoice(
2727
class ResponseValue(
2828
val invoices: List<Invoice?>,
2929
) : UseCase.ResponseValue
30-
3130
override fun executeUseCase(requestValues: RequestValues) {
3231
val paymentLink = requestValues.uniquePaymentLink
3332
try {
3433
val params = paymentLink?.pathSegments
35-
val clientId = params?.get(0) // "clientId"
36-
val invoiceId = params?.get(1) // "invoiceId"
34+
val clientId = params?.get(0)?.toLong() // "clientId"
35+
val invoiceId = params?.get(1)?.toLong() // "invoiceId
3736
if (clientId != null && invoiceId != null) {
3837
mFineractRepository.fetchInvoice(clientId, invoiceId)
3938
.observeOn(AndroidSchedulers.mainThread())

core/data/src/main/java/org/mifospay/core/data/domain/usecase/invoice/FetchInvoices.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package org.mifospay.core.data.domain.usecase.invoice
1111

1212
import android.util.Log
13-
import com.mifospay.core.model.entity.Invoice
13+
import com.mifospay.core.model.entity.invoice.Invoice
1414
import org.mifospay.core.data.base.UseCase
1515
import org.mifospay.core.data.fineract.repository.FineractRepository
1616
import rx.Subscriber
@@ -28,7 +28,7 @@ class FetchInvoices(
2828
) : UseCase.ResponseValue
2929

3030
override fun executeUseCase(requestValues: RequestValues) {
31-
mFineractRepository.fetchInvoices(requestValues.clientId)
31+
mFineractRepository.fetchInvoices(requestValues.clientId.toLong())
3232
.observeOn(AndroidSchedulers.mainThread())
3333
.subscribeOn(Schedulers.io())
3434
.subscribe(
@@ -40,6 +40,7 @@ class FetchInvoices(
4040
}
4141

4242
override fun onNext(invoices: List<Invoice>) {
43+
Log.d("invoice@@@", invoices.toString())
4344
useCaseCallback.onSuccess(ResponseValue(invoices))
4445
}
4546
},

core/data/src/main/java/org/mifospay/core/data/fineract/repository/FineractRepository.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import com.mifospay.core.model.domain.twofactor.AccessToken
1616
import com.mifospay.core.model.domain.twofactor.DeliveryMethod
1717
import com.mifospay.core.model.domain.user.NewUser
1818
import com.mifospay.core.model.domain.user.User
19-
import com.mifospay.core.model.entity.Invoice
2019
import com.mifospay.core.model.entity.Page
2120
import com.mifospay.core.model.entity.SearchedEntity
2221
import com.mifospay.core.model.entity.TPTResponse
@@ -30,6 +29,8 @@ import com.mifospay.core.model.entity.beneficary.BeneficiaryPayload
3029
import com.mifospay.core.model.entity.beneficary.BeneficiaryUpdatePayload
3130
import com.mifospay.core.model.entity.client.Client
3231
import com.mifospay.core.model.entity.client.ClientAccounts
32+
import com.mifospay.core.model.entity.invoice.Invoice
33+
import com.mifospay.core.model.entity.invoice.InvoiceEntity
3334
import com.mifospay.core.model.entity.kyc.KYCLevel1Details
3435
import com.mifospay.core.model.entity.payload.StandingInstructionPayload
3536
import com.mifospay.core.model.entity.payload.TransferPayload
@@ -206,24 +207,30 @@ class FineractRepository(
206207
)
207208
}
208209

209-
fun addInvoice(clientId: String, invoice: Invoice?): Observable<GenericResponse> {
210-
return fineractApiManager.invoiceApi.addInvoice(clientId, invoice)
210+
fun addInvoice(clientId: Long, invoice: InvoiceEntity?): Observable<Unit> {
211+
return Observable.fromCallable {
212+
fineractApiManager.invoiceApi.addInvoice(clientId, invoice)
213+
}
211214
}
212215

213-
fun fetchInvoices(clientId: String): Observable<List<Invoice>> {
216+
fun fetchInvoices(clientId: Long): Observable<List<Invoice>> {
214217
return fineractApiManager.invoiceApi.getInvoices(clientId)
215218
}
216219

217-
fun fetchInvoice(clientId: String, invoiceId: String): Observable<List<Invoice>> {
220+
fun fetchInvoice(clientId: Long, invoiceId: Long): Observable<List<Invoice>> {
218221
return fineractApiManager.invoiceApi.getInvoice(clientId, invoiceId)
219222
}
220223

221-
fun editInvoice(clientId: String, invoice: Invoice): Observable<GenericResponse> {
222-
return fineractApiManager.invoiceApi.updateInvoice(clientId, invoice.id, invoice)
224+
fun editInvoice(clientId: Long, invoice: Invoice): Observable<Unit> {
225+
return Observable.fromCallable {
226+
fineractApiManager.invoiceApi.updateInvoice(clientId, invoice.id, invoice)
227+
}
223228
}
224229

225-
fun deleteInvoice(clientId: String, invoiceId: Int): Observable<GenericResponse> {
226-
return fineractApiManager.invoiceApi.deleteInvoice(clientId, invoiceId)
230+
fun deleteInvoice(clientId: Long, invoiceId: Long): Observable<Unit> {
231+
return Observable.fromCallable {
232+
fineractApiManager.invoiceApi.deleteInvoice(clientId, invoiceId)
233+
}
227234
}
228235

229236
val users: Observable<List<UserWithRole>>

core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/IconBox.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.compose.material3.OutlinedIconButton
1717
import androidx.compose.material3.Surface
1818
import androidx.compose.runtime.Composable
1919
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.graphics.Color
2021
import androidx.compose.ui.graphics.vector.ImageVector
2122
import androidx.compose.ui.tooling.preview.Preview
2223
import androidx.compose.ui.unit.dp
@@ -28,17 +29,26 @@ fun IconBox(
2829
icon: ImageVector,
2930
onClick: () -> Unit,
3031
modifier: Modifier = Modifier,
32+
tint: Color? = null,
3133
) {
3234
OutlinedIconButton(
3335
onClick = onClick,
3436
modifier = modifier,
3537
shape = RoundedCornerShape(12.dp),
3638
border = BorderStroke(2.dp, MaterialTheme.colorScheme.onSurface.copy(alpha = 0.1f)),
3739
) {
38-
Icon(
39-
imageVector = icon,
40-
contentDescription = icon.name,
41-
)
40+
if (tint != null) {
41+
Icon(
42+
imageVector = icon,
43+
contentDescription = icon.name,
44+
tint = tint,
45+
)
46+
} else {
47+
Icon(
48+
imageVector = icon,
49+
contentDescription = icon.name,
50+
)
51+
}
4252
}
4353
}
4454

core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/MifosScaffold.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ fun MifosScaffold(
2323
backPress: () -> Unit,
2424
modifier: Modifier = Modifier,
2525
topBarTitle: Int? = null,
26+
titleColor: Color? = MaterialTheme.colorScheme.onSurface,
27+
iconTint: Color? = null,
2628
floatingActionButtonContent: FloatingActionButtonContent? = null,
2729
snackbarHost: @Composable () -> Unit = {},
2830
scaffoldContent: @Composable (PaddingValues) -> Unit = {},
@@ -35,6 +37,8 @@ fun MifosScaffold(
3537
topBarTitle = topBarTitle,
3638
backPress = backPress,
3739
actions = actions,
40+
titleColor = titleColor,
41+
iconTint = iconTint,
3842
)
3943
}
4044
},

core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/MifosTopBar.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ fun MifosTopBar(
2828
backPress: () -> Unit,
2929
modifier: Modifier = Modifier,
3030
actions: @Composable RowScope.() -> Unit = {},
31+
titleColor: Color? = null,
32+
iconTint: Color? = null,
3133
) {
3234
CenterAlignedTopAppBar(
3335
title = {
3436
Text(
3537
text = stringResource(id = topBarTitle),
3638
style = MaterialTheme.typography.titleMedium,
39+
color = titleColor ?: MaterialTheme.colorScheme.onSurface,
3740
)
3841
},
3942
navigationIcon = {
4043
IconBox(
4144
icon = MifosIcons.ArrowBack2,
4245
onClick = backPress,
46+
tint = iconTint,
4347
)
4448
},
4549
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(

core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/icon/MifosIcons.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.material.icons.filled.ArrowOutward
1616
import androidx.compose.material.icons.filled.AttachMoney
1717
import androidx.compose.material.icons.filled.Camera
1818
import androidx.compose.material.icons.filled.Check
19+
import androidx.compose.material.icons.filled.CheckCircleOutline
1920
import androidx.compose.material.icons.filled.ChevronLeft
2021
import androidx.compose.material.icons.filled.ChevronRight
2122
import androidx.compose.material.icons.filled.Close
@@ -30,6 +31,7 @@ import androidx.compose.material.icons.filled.Photo
3031
import androidx.compose.material.icons.filled.PhotoLibrary
3132
import androidx.compose.material.icons.filled.QrCode
3233
import androidx.compose.material.icons.filled.QrCode2
34+
import androidx.compose.material.icons.filled.RemoveCircleOutline
3335
import androidx.compose.material.icons.filled.Share
3436
import androidx.compose.material.icons.filled.Visibility
3537
import androidx.compose.material.icons.filled.VisibilityOff
@@ -99,4 +101,6 @@ object MifosIcons {
99101
val QrCode2 = Icons.Filled.QrCode2
100102
val Edit = Icons.Filled.Edit
101103
val Edit2 = Icons.Outlined.Edit
104+
val CheckCircle = Icons.Default.CheckCircleOutline
105+
val CheckCircle2 = Icons.Default.RemoveCircleOutline
102106
}

core/model/src/main/java/com/mifospay/core/model/entity/Invoice.kt

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
9+
*/
10+
package com.mifospay.core.model.entity.invoice
11+
12+
import android.os.Parcelable
13+
import com.google.gson.annotations.SerializedName
14+
import kotlinx.parcelize.Parcelize
15+
16+
@Parcelize
17+
data class Invoice(
18+
val id: Long,
19+
@SerializedName("client_id")
20+
val clientId: Long,
21+
val consumerId: String,
22+
val consumerName: String,
23+
val amount: Double,
24+
@SerializedName("itemsbought")
25+
val itemsBought: String,
26+
val status: Long,
27+
val transactionId: String,
28+
val invoiceId: Long,
29+
val title: String,
30+
val date: String,
31+
@SerializedName("created_at")
32+
val createdAt: List<Long>,
33+
@SerializedName("updated_at")
34+
val updatedAt: List<Long>,
35+
) : Parcelable
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
9+
*/
10+
package com.mifospay.core.model.entity.invoice
11+
12+
import kotlinx.serialization.SerialName
13+
import kotlinx.serialization.Serializable
14+
15+
@Serializable
16+
data class InvoiceEntity(
17+
val id: Long,
18+
val invoiceId: Long,
19+
val consumerId: String,
20+
val consumerName: String,
21+
val amount: Double,
22+
@SerialName("itemsbought")
23+
val itemsBought: String,
24+
val status: Long,
25+
val transactionId: String,
26+
val title: String,
27+
val date: String,
28+
val locale: String,
29+
val dateFormat: String,
30+
)

0 commit comments

Comments
 (0)