Skip to content

Commit 4eee289

Browse files
committed
release-1.0.0 fix: 3차 qa 이슈 대응
1 parent 3556631 commit 4eee289

14 files changed

Lines changed: 105 additions & 61 deletions

File tree

.idea/deploymentTargetDropDown.xml

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
applicationId = "com.moneymong.moneymong"
2424
minSdk = 24
2525
targetSdk = 34
26-
versionCode = 3
26+
versionCode = 4
2727
versionName = "1.0.0"
2828

2929
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

core/network/src/main/java/com/moneymong/moneymong/network/response/user/UserResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ data class UserResponse(
88
val name: String,
99
val email: String,
1010
@SerializedName("universityName")
11-
val university: String,
11+
val university: String?,
1212
val grade: Int
1313
)

domain/src/main/java/com/moneymong/moneymong/domain/entity/user/UserEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ data class UserEntity(
44
val id: Long,
55
val name: String,
66
val email: String,
7-
val university: String,
7+
val university: String?,
88
val grade: Int
99
)

feature/ledger/src/main/java/com/moneymong/moneymong/ledger/LedgerScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun LedgerScreen(
7373
padding: PaddingValues,
7474
navigateToAgency: () -> Unit,
7575
navigateToOCR: (NavOptions?) -> Unit,
76-
navigateToLedgerDetail: (NavOptions?, Int) -> Unit,
76+
navigateToLedgerDetail: (NavOptions?, Int, Boolean) -> Unit,
7777
navigateToLedgerManual: (NavOptions?) -> Unit
7878
) {
7979
val state = viewModel.collectAsState().value
@@ -111,7 +111,7 @@ fun LedgerScreen(
111111
viewModel.collectSideEffect {
112112
when (it) {
113113
is LedgerSideEffect.LedgerNavigateToLedgerDetail -> {
114-
navigateToLedgerDetail(null, it.id)
114+
navigateToLedgerDetail(null, it.id, state.isStaff)
115115
}
116116

117117
is LedgerSideEffect.LedgerNavigateToOCR -> {
@@ -338,7 +338,7 @@ fun LedgerScreenPreview() {
338338
padding = PaddingValues(),
339339
navigateToAgency = {},
340340
navigateToOCR = {},
341-
navigateToLedgerDetail = { navOptions, i -> },
341+
navigateToLedgerDetail = { navOptions, i, b -> },
342342
navigateToLedgerManual = {}
343343
)
344344
}

feature/ledger/src/main/java/com/moneymong/moneymong/ledger/navigation/LedgerNavigation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fun NavGraphBuilder.ledgerScreen(
3535
padding: PaddingValues,
3636
navigateToAgency: () -> Unit,
3737
navigateToOCR: (NavOptions?) -> Unit,
38-
navigateToLedgerDetail: (NavOptions?, Int) -> Unit,
38+
navigateToLedgerDetail: (NavOptions?, Int, Boolean) -> Unit,
3939
navigateToLedgerManual: (NavOptions?) -> Unit
4040
) {
4141
composable(

feature/ledgerdetail/src/main/java/com/moneymong/moneymong/ledgerdetail/LedgerDetailScreen.kt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import com.moneymong.moneymong.design_system.component.textfield.util.MDSTextFie
5656
import com.moneymong.moneymong.design_system.component.textfield.visualtransformation.DateVisualTransformation
5757
import com.moneymong.moneymong.design_system.component.textfield.visualtransformation.PriceVisualTransformation
5858
import com.moneymong.moneymong.design_system.component.textfield.visualtransformation.TimeVisualTransformation
59+
import com.moneymong.moneymong.design_system.error.ErrorDialog
5960
import com.moneymong.moneymong.design_system.loading.LoadingScreen
6061
import com.moneymong.moneymong.design_system.theme.Blue01
6162
import com.moneymong.moneymong.design_system.theme.Blue03
@@ -143,6 +144,12 @@ fun LedgerDetailScreen(
143144
)
144145
}
145146

147+
if (state.showErrorDialog) {
148+
ErrorDialog(message = state.errorMessage) {
149+
viewModel.onChangeErrorDialogVisible(false)
150+
}
151+
}
152+
146153
if (state.showConfirmModal) {
147154
MDSModal(
148155
icon = R.drawable.ic_warning_filled,
@@ -529,27 +536,29 @@ fun LedgerDetailScreen(
529536
)
530537
}
531538
}
532-
if (state.useEditMode) {
533-
MDSButton(
534-
modifier = Modifier
535-
.fillMaxWidth()
536-
.padding(vertical = 24.dp, horizontal = 20.dp),
537-
text = "완료하기",
538-
enabled = state.enabledEdit,
539-
size = MDSButtonSize.MEDIUM,
540-
type = MDSButtonType.PRIMARY,
541-
onClick = { viewModel.eventEmit(LedgerDetailSideEffect.LedgerDetailEditDone) }
542-
)
543-
} else {
544-
MDSButton(
545-
modifier = Modifier
546-
.fillMaxWidth()
547-
.padding(vertical = 24.dp, horizontal = 20.dp),
548-
text = "수정하기",
549-
size = MDSButtonSize.MEDIUM,
550-
type = MDSButtonType.PRIMARY,
551-
onClick = { viewModel.eventEmit(LedgerDetailSideEffect.LedgerDetailEdit) }
552-
)
539+
if (state.isStaff) {
540+
if (state.useEditMode) {
541+
MDSButton(
542+
modifier = Modifier
543+
.fillMaxWidth()
544+
.padding(vertical = 24.dp, horizontal = 20.dp),
545+
text = "완료하기",
546+
enabled = state.enabledEdit,
547+
size = MDSButtonSize.MEDIUM,
548+
type = MDSButtonType.PRIMARY,
549+
onClick = { viewModel.eventEmit(LedgerDetailSideEffect.LedgerDetailEditDone) }
550+
)
551+
} else {
552+
MDSButton(
553+
modifier = Modifier
554+
.fillMaxWidth()
555+
.padding(vertical = 24.dp, horizontal = 20.dp),
556+
text = "수정하기",
557+
size = MDSButtonSize.MEDIUM,
558+
type = MDSButtonType.PRIMARY,
559+
onClick = { viewModel.eventEmit(LedgerDetailSideEffect.LedgerDetailEdit) }
560+
)
561+
}
553562
}
554563
}
555564
}

feature/ledgerdetail/src/main/java/com/moneymong/moneymong/ledgerdetail/LedgerDetailState.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.time.format.DateTimeFormatter
1414
import java.util.Locale
1515

1616
data class LedgerDetailState(
17-
val isLoading: Boolean = false,
17+
val isLoading: Boolean = true,
1818
val useEditMode: Boolean = false,
1919
val storeNameValue: TextFieldValue = TextFieldValue(),
2020
val totalPriceValue: TextFieldValue = TextFieldValue(),
@@ -33,6 +33,9 @@ data class LedgerDetailState(
3333
val receiptIdList: List<Int> = emptyList(),
3434
val documentIdList: List<Int> = emptyList(),
3535
val showConfirmModal: Boolean = false,
36+
val showErrorDialog: Boolean = false,
37+
val errorMessage: String = "",
38+
val isStaff: Boolean = false
3639
) : State {
3740

3841
val fundTypeText: String
@@ -67,5 +70,10 @@ data class LedgerDetailState(
6770
}
6871

6972
val enabledEdit: Boolean
70-
get() = !isStoreNameError && !isTotalPriceError && !isPaymentDateError && !isPaymentTimeError && !isMemoError
71-
}
73+
get() {
74+
val hasStoreName = !isStoreNameError && storeNameValue.text.isNotEmpty()
75+
val hasTotalPrice = !isTotalPriceError && totalPriceValue.text.isNotEmpty()
76+
val hasPaymentDate = !isPaymentDateError && paymentDateValue.text.isNotEmpty()
77+
val hasPaymentTime = !isPaymentTimeError && paymentTimeValue.text.isNotEmpty()
78+
return hasStoreName && hasTotalPrice && hasPaymentDate && hasPaymentTime && !isMemoError
79+
}}

feature/ledgerdetail/src/main/java/com/moneymong/moneymong/ledgerdetail/LedgerDetailViewModel.kt

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.moneymong.moneymong.ledgerdetail
22

33
import androidx.compose.ui.text.input.TextFieldValue
4+
import androidx.lifecycle.SavedStateHandle
45
import com.moneymong.moneymong.common.base.BaseViewModel
6+
import com.moneymong.moneymong.common.error.MoneyMongError
57
import com.moneymong.moneymong.common.ext.toDateFormat
68
import com.moneymong.moneymong.common.ui.isValidPaymentDate
79
import com.moneymong.moneymong.common.ui.isValidPaymentTime
@@ -21,17 +23,21 @@ import com.moneymong.moneymong.domain.usecase.ledgerdetail.PostLedgerDocumentTra
2123
import com.moneymong.moneymong.domain.usecase.ledgerdetail.PostLedgerReceiptTransactionUseCase
2224
import com.moneymong.moneymong.domain.usecase.ledgerdetail.UpdateLedgerTransactionDetailUseCase
2325
import com.moneymong.moneymong.domain.usecase.ocr.PostFileUploadUseCase
26+
import com.moneymong.moneymong.ledgerdetail.navigation.LedgerDetailArgs
2427
import dagger.hilt.android.lifecycle.HiltViewModel
2528
import kotlinx.coroutines.delay
29+
import org.orbitmvi.orbit.annotation.OrbitExperimental
2630
import org.orbitmvi.orbit.syntax.simple.blockingIntent
2731
import org.orbitmvi.orbit.syntax.simple.intent
2832
import org.orbitmvi.orbit.syntax.simple.postSideEffect
2933
import org.orbitmvi.orbit.syntax.simple.reduce
3034
import java.io.File
3135
import javax.inject.Inject
3236

37+
@OptIn(OrbitExperimental::class)
3338
@HiltViewModel
3439
class LedgerDetailViewModel @Inject constructor(
40+
savedStateHandle: SavedStateHandle,
3541
private val fetchLedgerTransactionDetailUseCase: FetchLedgerTransactionDetailUseCase,
3642
private val updateLedgerTransactionDetailUseCase: UpdateLedgerTransactionDetailUseCase,
3743
private val postLedgerReceiptTransactionUseCase: PostLedgerReceiptTransactionUseCase,
@@ -42,6 +48,10 @@ class LedgerDetailViewModel @Inject constructor(
4248
private val deleteLedgerDetailUseCase: DeleteLedgerDetailUseCase
4349
) : BaseViewModel<LedgerDetailState, LedgerDetailSideEffect>(LedgerDetailState()) {
4450

51+
init {
52+
onChangeStaffStatus(isStaff = LedgerDetailArgs(savedStateHandle).isStaff)
53+
}
54+
4555
fun ledgerTransactionEdit(detailId: Int) = intent {
4656
postLedgerReceiptTransaction(detailId)
4757
deleteLedgerReceiptTransaction(detailId)
@@ -57,7 +67,7 @@ class LedgerDetailViewModel @Inject constructor(
5767
reduce { state.copy(ledgerTransactionDetail = it) }
5868
initTextValue(it)
5969
}.onFailure {
60-
// TODO
70+
showErrorDialog(it.message)
6171
}.also { reduce { state.copy(isLoading = false) } }
6272
}
6373

@@ -76,7 +86,7 @@ class LedgerDetailViewModel @Inject constructor(
7686
reduce { state.copy(ledgerTransactionDetail = it) }
7787
initTextValue(it)
7888
}.onFailure {
79-
// TODO
89+
showErrorDialog(it.message)
8090
}.also { reduce { state.copy(isLoading = false) } }
8191
}
8292

@@ -92,7 +102,7 @@ class LedgerDetailViewModel @Inject constructor(
92102
)
93103
postLedgerReceiptTransactionUseCase(param)
94104
.onFailure {
95-
// TODO
105+
showErrorDialog(it.message)
96106
}.also { reduce { state.copy(isLoading = false) } }
97107
}
98108
}
@@ -109,7 +119,7 @@ class LedgerDetailViewModel @Inject constructor(
109119
)
110120
postLedgerDocumentTransactionUseCase(param)
111121
.onFailure {
112-
// TODO
122+
showErrorDialog(it.message)
113123
}.also { reduce { state.copy(isLoading = false) } }
114124
}
115125
}
@@ -121,7 +131,7 @@ class LedgerDetailViewModel @Inject constructor(
121131
val param = DeleteLedgerReceiptParam(detailId = detailId, receiptId = receiptId)
122132
deleteLedgerReceiptTransactionUseCase(param)
123133
.onFailure {
124-
// TODO
134+
showErrorDialog(it.message)
125135
}.also { reduce { state.copy(isLoading = false) } }
126136
}
127137
}
@@ -134,7 +144,7 @@ class LedgerDetailViewModel @Inject constructor(
134144
val param = DeleteLedgerDocumentParam(detailId = detailId, documentId = documentId)
135145
deleteLedgerDocumentTransactionUseCase(param)
136146
.onFailure {
137-
// TODO
147+
showErrorDialog(it.message)
138148
}.also { reduce { state.copy(isLoading = false) } }
139149
}
140150
}
@@ -146,7 +156,7 @@ class LedgerDetailViewModel @Inject constructor(
146156
.onSuccess {
147157
postSideEffect(LedgerDetailSideEffect.LedgerDetailNavigateToLedger)
148158
}.onFailure {
149-
// TODO
159+
showErrorDialog(it.message)
150160
}.also { reduce { state.copy(isLoading = false) } }
151161
}
152162

@@ -165,7 +175,7 @@ class LedgerDetailViewModel @Inject constructor(
165175
}
166176
}
167177
}.onFailure {
168-
// TODO
178+
showErrorDialog(it.message)
169179
}.also {
170180
reduce {
171181
state.copy(
@@ -320,6 +330,23 @@ class LedgerDetailViewModel @Inject constructor(
320330
reduce { state.copy(showConfirmModal = visible) }
321331
}
322332

333+
fun onChangeErrorDialogVisible(visible: Boolean) = intent {
334+
reduce { state.copy(showErrorDialog = visible) }
335+
}
336+
337+
private fun onChangeStaffStatus(isStaff: Boolean) = intent {
338+
reduce { state.copy(isStaff = isStaff) }
339+
}
340+
341+
private fun showErrorDialog(message: String?) = intent {
342+
reduce {
343+
state.copy(
344+
showErrorDialog = true,
345+
errorMessage = message ?: MoneyMongError.UnExpectedError.message
346+
)
347+
}
348+
}
349+
323350
companion object {
324351
const val MAX_TOTAL_PRICE = 999999999
325352
}

feature/ledgerdetail/src/main/java/com/moneymong/moneymong/ledgerdetail/navigation/LedgerDetailNavigation.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.moneymong.moneymong.ledgerdetail.navigation
22

3+
import androidx.lifecycle.SavedStateHandle
34
import androidx.navigation.NavController
45
import androidx.navigation.NavGraphBuilder
56
import androidx.navigation.NavOptions
@@ -9,13 +10,16 @@ import androidx.navigation.navArgument
910
import com.moneymong.moneymong.ledgerdetail.LedgerDetailScreen
1011

1112
const val LEDGER_TRANSACTION_ID = "ledgerTransactionId"
12-
const val ledgerDetailRoute = "ledgerDetail_route/{${LEDGER_TRANSACTION_ID}}"
13+
const val LEDGER_DETAIL_IS_STAFF = "LedgerDetailIsStaff"
14+
const val ledgerDetailRoute = "ledgerDetail_route/{${LEDGER_TRANSACTION_ID}}/{${LEDGER_DETAIL_IS_STAFF}}"
15+
//const val ledgerDetailRouteWithArgs = "${ledgerDetailRoute}/{${LEDGER_DETAIL_IS_STAFF}}"
1316

1417
fun NavController.navigateLedgerDetail(
1518
navOptions: NavOptions? = null,
16-
ledgerTransactionId: Int
19+
ledgerTransactionId: Int,
20+
isStaff: Boolean = false,
1721
) {
18-
this.navigate("ledgerDetail_route/${ledgerTransactionId}", navOptions)
22+
this.navigate("ledgerDetail_route/${ledgerTransactionId}/${isStaff}", navOptions)
1923
}
2024

2125
fun NavGraphBuilder.ledgerDetailScreen(
@@ -25,7 +29,11 @@ fun NavGraphBuilder.ledgerDetailScreen(
2529
composable(
2630
route = ledgerDetailRoute,
2731
arguments = listOf(
28-
navArgument(LEDGER_TRANSACTION_ID) { type = NavType.IntType }
32+
navArgument(LEDGER_TRANSACTION_ID) { type = NavType.IntType },
33+
navArgument(LEDGER_DETAIL_IS_STAFF) {
34+
type = NavType.BoolType
35+
defaultValue = false
36+
}
2937
)
3038
) { backStackEntry ->
3139
val ledgerTransactionId = backStackEntry.arguments?.getInt(LEDGER_TRANSACTION_ID) ?: 0
@@ -35,4 +43,10 @@ fun NavGraphBuilder.ledgerDetailScreen(
3543
popBackStack = popBackStack
3644
)
3745
}
46+
}
47+
48+
internal class LedgerDetailArgs(val isStaff: Boolean) {
49+
constructor(savedStateHandle: SavedStateHandle) : this(
50+
isStaff = checkNotNull(savedStateHandle[LEDGER_DETAIL_IS_STAFF])
51+
)
3852
}

0 commit comments

Comments
 (0)