Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Migrated Receipt Module to KMP #1801

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ that can be used as a dependency in any other wallet based project. It is develo
| :feature:merchants | Not started | ❌ | ❌ | ❌ | ❌ | ❌ |
| :feature:notification | Done | ✅ | ✅ | ❔ | ✅ | ❔ |
| :feature:qr | Not started | ❌ | ❌ | ❌ | ❌ | ❌ |
| :feature:receipt | Not started | ❌ | | | | |
| :feature:receipt | Done | ✅ | | | | |
| :feature:request-money | Not started | ❌ | ❌ | ❌ | ❌ | ❌ |
| :feature:saved-cards | Done | ✅ | ✅ | ❔ | ✅ | ❔ |
| :feature:search | Not started | ❌ | ❌ | ❌ | ❌ | ❌ |
178 changes: 178 additions & 0 deletions feature/receipt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Download & View Receipt Feature

This feature is responsible for download and view the transaction receipt. unfortunately,
this functionality of this feature is not working. due to configuration issue of `Savings Transaction Receipt` run report API.
Tested in Web, Postman and Swagger, but it's not working.

And this feature could be merge with `Accounting` feature, to download the transaction receipt.


## Receiving Template of the Receipt
``` json
{
"id": 157,
"reportName": "Savings Transaction Receipt",
"reportType": "Pentaho",
"coreReport": false,
"useReport": true,
"reportParameters": [
{
"id": 426,
"parameterId": 1006,
"parameterName": "transactionId",
"reportParameterName": "transactionId"
}
],
"allowedReportTypes": [
"Table",
"Chart",
"SMS"
],
"allowedReportSubTypes": [
"Bar",
"Pie"
],
"allowedParameters": [
{
"id": 1,
"parameterName": "startDateSelect"
},
{
"id": 2,
"parameterName": "endDateSelect"
},
{
"id": 3,
"parameterName": "obligDateTypeSelect"
},
{
"id": 5,
"parameterName": "OfficeIdSelectOne"
},
{
"id": 6,
"parameterName": "loanOfficerIdSelectAll"
},
{
"id": 10,
"parameterName": "currencyIdSelectAll"
},
{
"id": 20,
"parameterName": "fundIdSelectAll"
},
{
"id": 25,
"parameterName": "loanProductIdSelectAll"
},
{
"id": 26,
"parameterName": "loanPurposeIdSelectAll"
},
{
"id": 100,
"parameterName": "parTypeSelect"
},
{
"id": 1004,
"parameterName": "selectAccount"
},
{
"id": 1005,
"parameterName": "savingsProductIdSelectAll"
},
{
"id": 1006,
"parameterName": "transactionId"
},
{
"id": 1007,
"parameterName": "selectCenterId"
},
{
"id": 1008,
"parameterName": "SelectGLAccountNO"
},
{
"id": 1009,
"parameterName": "asOnDate"
},
{
"id": 1010,
"parameterName": "SavingsAccountSubStatus"
},
{
"id": 1011,
"parameterName": "cycleXSelect"
},
{
"id": 1012,
"parameterName": "cycleYSelect"
},
{
"id": 1013,
"parameterName": "fromXSelect"
},
{
"id": 1014,
"parameterName": "toYSelect"
},
{
"id": 1015,
"parameterName": "overdueXSelect"
},
{
"id": 1016,
"parameterName": "overdueYSelect"
},
{
"id": 1017,
"parameterName": "DefaultLoan"
},
{
"id": 1018,
"parameterName": "DefaultClient"
},
{
"id": 1019,
"parameterName": "DefaultGroup"
},
{
"id": 1020,
"parameterName": "SelectLoanType"
},
{
"id": 1021,
"parameterName": "DefaultSavings"
},
{
"id": 1022,
"parameterName": "DefaultSavingsTransactionId"
}
]
}
```

## Error Receiving From API

``` json
{
"developerMessage": "The server is currently unable to handle the request , please try after some time.",
"httpStatusCode": "503",
"defaultUserMessage": "The server is currently unable to handle the request , please try after some time.",
"userMessageGlobalisationCode": "error.msg.platform.service.unavailable",
"errors": [
{
"developerMessage": "There is no ReportingProcessService registered in the ReportingProcessServiceProvider for this report type: Pentaho",
"defaultUserMessage": "There is no ReportingProcessService registered in the ReportingProcessServiceProvider for this report type: Pentaho",
"userMessageGlobalisationCode": "err.msg.report.service.implementation.missing",
"parameterName": "id",
"args": [
{
"value": "Pentaho"
}
]
}
]
}
```
20 changes: 14 additions & 6 deletions feature/receipt/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -8,15 +8,23 @@
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifospay.android.feature)
alias(libs.plugins.mifospay.android.library.compose)
alias(libs.plugins.mifospay.cmp.feature)
alias(libs.plugins.kotlin.parcelize)
}

android {
namespace = "org.mifospay.receipt"
namespace = "org.mifospay.feature.receipt"
}

dependencies {
// TODO:: this should be removed
implementation(libs.squareup.okhttp)
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.squareup.okio)
}
}
}
Empty file removed feature/receipt/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions feature/receipt/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.receipt

import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import mobile_wallet.feature.receipt.generated.resources.Res
import mobile_wallet.feature.receipt.generated.resources.feature_receipt_loading
import mobile_wallet.feature.receipt.generated.resources.feature_receipt_receipt
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel
import org.mifospay.core.designsystem.component.MifosLoadingWheel
import org.mifospay.core.designsystem.component.MifosScaffold
import org.mifospay.core.ui.EmptyContentScreen

@Composable
internal fun ReceiptScreenRoute(
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
viewModel: ReceiptViewModel = koinViewModel(),
) {
val receiptUiState by viewModel.receiptUiState.collectAsState()

ReceiptScreen(
uiState = receiptUiState,
onBackClick = onBackClick,
modifier = modifier,
)
}

@Composable
@VisibleForTesting
internal fun ReceiptScreen(
uiState: ReceiptUiState,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
MifosScaffold(
backPress = onBackClick,
topBarTitle = stringResource(Res.string.feature_receipt_receipt),
) {
Box(
modifier = modifier
.fillMaxSize()
.padding(it),
) {
when (uiState) {
is ReceiptUiState.Loading -> {
MifosLoadingWheel(
contentDesc = stringResource(Res.string.feature_receipt_loading),
)
}

is ReceiptUiState.Error -> {
EmptyContentScreen(
title = "Oops!",
subTitle = uiState.message,
)
}

is ReceiptUiState.Success -> {
EmptyContentScreen(
title = "Oops!",
subTitle = "Not implemented yet",
)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.receipt

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import org.mifospay.core.model.savingsaccount.Transaction
import org.mifospay.core.model.savingsaccount.TransferDetail

class ReceiptViewModel(
savedStateHandle: SavedStateHandle,
) : ViewModel() {
private val mReceiptState =
MutableStateFlow<ReceiptUiState>(ReceiptUiState.Error("Not implemented yet"))
val receiptUiState: StateFlow<ReceiptUiState> = mReceiptState.asStateFlow()
}

sealed interface ReceiptUiState {
data class Success(
val transaction: Transaction,
val transferDetail: TransferDetail,
val receiptLink: String,
) : ReceiptUiState

data class Error(
val message: String,
) : ReceiptUiState

data object Loading : ReceiptUiState
}
Original file line number Diff line number Diff line change
@@ -9,19 +9,10 @@
*/
package org.mifospay.feature.receipt.di

import org.koin.core.module.dsl.viewModel
import org.koin.core.module.dsl.viewModelOf
import org.koin.dsl.module
import org.mifospay.feature.receipt.ReceiptViewModel

val ReceiptModule = module {
viewModel {
ReceiptViewModel(
mUseCaseHandler = get(),
preferencesHelper = get(),
downloadTransactionReceiptUseCase = get(),
fetchAccountTransactionUseCase = get(),
fetchAccountTransferUseCase = get(),
savedStateHandle = get(),
)
}
viewModelOf(::ReceiptViewModel)
}
Loading
Loading