-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(bank-sdk): Skonto + RA validation implementation
PP-795
- Loading branch information
1 parent
109538e
commit 115cafe
Showing
7 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ndroid/bank/sdk/capture/digitalinvoice/skonto/mapper/SkontoAmountValidationErrorMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.gini.android.bank.sdk.capture.digitalinvoice.skonto.mapper | ||
|
||
import android.content.res.Resources | ||
import net.gini.android.bank.sdk.R | ||
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.DigitalInvoiceSkontoScreenState | ||
|
||
internal fun DigitalInvoiceSkontoScreenState.Ready.SkontoAmountValidationError.toErrorMessage( | ||
resources: Resources, | ||
): String = when (this) { | ||
is DigitalInvoiceSkontoScreenState.Ready.SkontoAmountValidationError.SkontoAmountMoreThanFullAmount -> | ||
resources.getString( | ||
R.string.gbs_skonto_section_discount_field_amount_validation_error_skonto_amount_more_than_full_amount | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
.../bank/sdk/capture/digitalinvoice/skonto/validation/DigitalInvoiceSkontoAmountValidator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.gini.android.bank.sdk.capture.digitalinvoice.skonto.validation | ||
|
||
import net.gini.android.bank.sdk.capture.digitalinvoice.skonto.DigitalInvoiceSkontoScreenState | ||
import java.math.BigDecimal | ||
|
||
internal class DigitalInvoiceSkontoAmountValidator { | ||
|
||
operator fun invoke(newSkontoAmount: BigDecimal, fullAmount: BigDecimal) | ||
: DigitalInvoiceSkontoScreenState.Ready.SkontoAmountValidationError? = when { | ||
newSkontoAmount > fullAmount -> | ||
DigitalInvoiceSkontoScreenState.Ready.SkontoAmountValidationError.SkontoAmountMoreThanFullAmount | ||
|
||
else -> null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters