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

Remove everything related to the old deposit return voucher logic (Apps-1644) #227

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
### Added
### Changed
### Removed
* ui/core: Remove everything related to the old deposit return voucher feature
### Fixed

## [0.79.0]
Expand Down
9 changes: 2 additions & 7 deletions core/src/main/java/io/snabble/sdk/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ public enum Type {
* A product that needs to be user weighed. The price from {@link Product#getListPrice()}
* is a base price of 1000g
*/
UserWeighed(2),

/**
* A product that is used for deposit return voucher's
*/
DepositReturnVoucher(3);
UserWeighed(2);

private final int databaseValue;

Expand Down Expand Up @@ -656,4 +651,4 @@ public Product build() {
return product;
}
}
}
}
8 changes: 2 additions & 6 deletions core/src/main/java/io/snabble/sdk/ProductApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ private enum ApiProductType {
@SerializedName("weighable")
WEIGHABLE,
@SerializedName("deposit")
DEPOSIT,
@SerializedName("depositReturnVoucher")
DEPOSIT_RETURN_VOUCHER
DEPOSIT
}

private static class ApiScannableCode {
Expand Down Expand Up @@ -281,8 +279,6 @@ private Product toProduct(ApiProduct apiProduct) {
} else {
builder.setType(Product.Type.PreWeighed);
}
} else if (apiProduct.productType == ApiProductType.DEPOSIT_RETURN_VOUCHER) {
builder.setType(Product.Type.DepositReturnVoucher);
} else {
builder.setType(Product.Type.Article);
}
Expand All @@ -306,4 +302,4 @@ private Product toProduct(ApiProduct apiProduct) {

return builder.build();
}
}
}
3 changes: 0 additions & 3 deletions core/src/main/java/io/snabble/sdk/ProductDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,6 @@ public Cursor searchByFoldedName(String searchString, CancellationSignal cancell
return productQuery("JOIN searchByName ns ON ns.sku = p.sku " +
"WHERE ns.foldedName MATCH ? " +
"AND p.weighing != " + Product.Type.PreWeighed.getDatabaseValue() + " " +
"AND p.weighing != " + Product.Type.DepositReturnVoucher.getDatabaseValue() + " " +
"AND p.isDeposit = 0 " +
"AND availability != 2 " +
"LIMIT 100", new String[]{
Expand Down Expand Up @@ -1439,8 +1438,6 @@ public Cursor searchByCode(String searchString, CancellationSignal cancellationS

sb.append(") AND p.weighing != ");
sb.append(Product.Type.PreWeighed.getDatabaseValue());
sb.append(" AND p.weighing != ");
sb.append(Product.Type.DepositReturnVoucher.getDatabaseValue());
sb.append(" AND p.isDeposit = 0 ");
sb.append(" AND availability != 2");

Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/io/snabble/sdk/checkout/Checkout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,6 @@ class Checkout @JvmOverloads constructor(
notifyStateChanged(CheckoutState.NO_PAYMENT_METHOD_AVAILABLE)
}

override fun onInvalidDepositReturnVoucher() {
notifyStateChanged(CheckoutState.CONNECTION_ERROR)
}

override fun onUnknownError() {
notifyStateChanged(CheckoutState.CONNECTION_ERROR)
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ interface CheckoutInfoResult {
fun onNoShopFound()
fun onInvalidProducts(products: List<Product>)
fun onNoAvailablePaymentMethodFound()
fun onInvalidDepositReturnVoucher()
fun onUnknownError()
fun onConnectionError()
}
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/io/snabble/sdk/checkout/CheckoutRetryer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ internal class CheckoutRetryer(project: Project, fallbackPaymentMethod: PaymentM
fail()
}

override fun onInvalidDepositReturnVoucher() {
fail()
}

override fun onUnknownError() {
fail()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class DefaultCheckoutApi(private val project: Project,
}
"no_available_method" -> checkoutInfoResult?.onNoAvailablePaymentMethodFound()
"bad_shop_id", "shop_not_found" -> checkoutInfoResult?.onNoShopFound()
"invalid_deposit_return_voucher" -> checkoutInfoResult?.onInvalidDepositReturnVoucher()
else -> checkoutInfoResult?.onUnknownError()
}
} catch (e: Exception) {
Expand Down
17 changes: 0 additions & 17 deletions core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ class ShoppingCart(
fun invalidateOnlinePrices() {
data = data.copy(
invalidProducts = null,
invalidDepositReturnVoucher = false,
onlineTotalPrice = null
)

Expand Down Expand Up @@ -420,10 +419,6 @@ class ShoppingCart(
val isOnlinePrice: Boolean
get() = data.onlineTotalPrice != null

fun setInvalidDepositReturnVoucher(invalidDepositReturnVoucher: Boolean) {
data = data.copy(invalidDepositReturnVoucher = invalidDepositReturnVoucher)
}

fun isCouponApplied(coupon: Coupon): Boolean = any { it?.coupon?.id == coupon.id }

fun removeCoupon(coupon: Coupon) {
Expand All @@ -440,8 +435,6 @@ class ShoppingCart(
data = data.copy(invalidProducts = invalidProducts)
}

fun hasInvalidDepositReturnVoucher(): Boolean = data.invalidDepositReturnVoucher

/**
* Returns the total price of the cart.
*
Expand Down Expand Up @@ -943,16 +936,6 @@ class ShoppingCart(
quantity = 1
}
}
if (scannedCode.hasEmbeddedData() && product.type == Type.DepositReturnVoucher) {
val builder = scannedCode.newBuilder()
if (scannedCode.hasEmbeddedData()) {
builder.setEmbeddedData(scannedCode.embeddedData * -1)
}
if (scannedCode.hasEmbeddedDecimalData()) {
builder.setEmbeddedDecimalData(scannedCode.embeddedDecimalData.multiply(BigDecimal(-1)))
}
this.scannedCode = builder.create()
}
}

constructor(cart: ShoppingCart, lineItem: LineItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data class ShoppingCartData @JvmOverloads constructor(
val taxation: Taxation = Taxation.UNDECIDED,
val hasReachedMaxCheckoutLimit: Boolean = false,
val hasReachedMaxOnlinePaymentLimit: Boolean = false,
val invalidDepositReturnVoucher: Boolean = false,
val backupTimestamp: Long = 0,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ internal class ShoppingCartUpdater(
error(requestSucceeded = true)
}

override fun onInvalidDepositReturnVoucher() {
cart.setInvalidDepositReturnVoucher(true)
error(requestSucceeded = true)
}

override fun onUnknownError() {
error(requestSucceeded = false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ class ShoppingCartView : FrameLayout {
updateEmptyState()
scanForImages()
checkSaleStop()
checkDepositReturnVoucher()
}
}

Expand Down Expand Up @@ -246,18 +245,6 @@ class ShoppingCartView : FrameLayout {
}
}

private fun checkDepositReturnVoucher() {
if (cart?.hasInvalidDepositReturnVoucher() == true && !hasAlreadyShownInvalidDeposit) {
AlertDialog.Builder(context)
.setCancelable(false)
.setTitle(getIdentifier(resources, R.string.Snabble_SaleStop_ErrorMsg_title))
.setMessage(getIdentifier(resources, R.string.Snabble_InvalidDepositVoucher_errorMsg))
.setPositiveButton(R.string.Snabble_ok, null)
.show()
hasAlreadyShownInvalidDeposit = true
}
}

private fun scanForImages() {
val lastHasAnyImages = hasAnyImages

Expand Down
6 changes: 0 additions & 6 deletions ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,6 @@ class ProductResolver private constructor(private val context: Context, private
progressDialog.dismiss()
onDismissListener?.onDismiss()
}
product.type == Product.Type.DepositReturnVoucher
&& project.shoppingCart.containsScannedCode(scannedCode) -> {
onAlreadyScannedListener?.onAlreadyScanned()
progressDialog.dismiss()
onDismissListener?.onDismiss()
}
onProductFoundListener != null -> {
onProductFoundListener?.onProductFound(product, scannedCode)
}
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<string name="Snabble.Hints.closedBags">Weiter so! Bitte mache es dem Kassenpersonal leicht und packe deine Artikel nicht direkt in geschlossene Taschen. Danke!</string>
<string name="Snabble.Hints.continueScanning">Weiter scannen</string>
<string name="Snabble.Hints.title">Hinweis von %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Leergutbons können nur einmal eingelöst werden.</string>
<string name="Snabble.Keyguard.message">Dadurch stellen wir sicher, dass nur du selbst Zugriff auf diese Zahlungsmethode hast</string>
<string name="Snabble.Keyguard.requireScreenLock">Du musst dein Smartphone mit einer Display-Sperre schützen, um diese Zahlungsmethode hinzuzufügen.</string>
<string name="Snabble.Keyguard.title">Bitte entsperre dein Smartphone</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-fr-rCH/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="Snabble.Hints.closedBags">Continue comme ça ! Merci de faciliter la tâche au personnel de caisse et de ne pas emballer tes articles directement dans des sacs fermés. Merci !</string>
<string name="Snabble.Hints.continueScanning">Continuer à scanner</string>
<string name="Snabble.Hints.title">Remarque de %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Les bons des emballages vides ne peuvent être encaissés qu’une seule fois.</string>
<string name="Snabble.Keyguard.message">De cette façon, nous nous assurons que tu es l’unique personne à pouvoir accéder à cette procédure de paiement.</string>
<string name="Snabble.Keyguard.requireScreenLock">Merci de protéger ton smartphone au moyen d’un verrouillage d’écran pour ajouter ce mode de paiement.</string>
<string name="Snabble.Keyguard.title">Merci de déverrouiller ton smartphone</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<string name="Snabble.Hints.closedBags">Parfait, continuez ! S\'il vous plaît, facilitez la tâche du personnel de caisse et ne déposez pas vos articles directement dans des sacs fermés. Merci !</string>
<string name="Snabble.Hints.continueScanning">Continuer à scanner</string>
<string name="Snabble.Hints.title">Avis de %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Les bons pour les emballages vides ne peuvent être échangés qu\'une seule fois.</string>
<string name="Snabble.Keyguard.message">Nous nous assurons ainsi que vous êtes le seul à avoir accès à ce mode de paiement.</string>
<string name="Snabble.Keyguard.requireScreenLock">Vous devez protéger votre smartphone avec un verrouillage d\'écran pour ajouter ce mode de paiement.</string>
<string name="Snabble.Keyguard.title">Veuillez déverrouiller votre smartphone</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<string name="Snabble.Hints.closedBags">Csak így tovább! Kérjük, könnyítsd meg a pénztáros munkáját, és ne csomagold közvetlenül lezárt tasakba a termékedet. Köszönjük!</string>
<string name="Snabble.Hints.continueScanning">Szkennelés folytatása</string>
<string name="Snabble.Hints.title">%s megjegyzése</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Az üvegvisszaváltó blokkot csak egyszer lehet beváltani.</string>
<string name="Snabble.Keyguard.message">Ezzel garantálható, hogy csak te férj ehhez a fizetési eljáráshoz</string>
<string name="Snabble.Keyguard.requireScreenLock">E fizetési mód hozzáadásához képernyőzárral kell védened az okostelefonod.</string>
<string name="Snabble.Keyguard.title">Kérlek, oldd fel az okostelefonod képernyőzárát</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="Snabble.Hints.closedBags">Continua così! Agevola il compito del personale di cassa ed evita di mettere direttamente gli articoli in borse chiuse. Grazie!</string>
<string name="Snabble.Hints.continueScanning">Continua la scansione</string>
<string name="Snabble.Hints.title">Nota di %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Gli scontrini dei vuoti possono essere riscattati una sola volta.</string>
<string name="Snabble.Keyguard.message">In questo modo ci assicuriamo che solo tu abbia accesso a questa modalità di pagamento</string>
<string name="Snabble.Keyguard.requireScreenLock">È necessario proteggere il tuo smartphone con un blocco schermo per poter aggiungere questo metodo di pagamento.</string>
<string name="Snabble.Keyguard.title">Sblocca il tuo smartphone</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
<string name="Snabble.Hints.closedBags">Len tak ďalej! Prosím, uľahči prácu pokladníkom a nevkladaj svoje produkty priamo do uzavretých tašiek. Ďakujem!</string>
<string name="Snabble.Hints.continueScanning">Pokračovať v skenovaní</string>
<string name="Snabble.Hints.title">Poznámka od %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Poukážky za vratné produkty môžu byť uplatnené len jedenkrát.</string>
<string name="Snabble.Keyguard.message">Tým zabezpečíme, že k tomuto spôsobu platby budeš mať prístup len ty sám/sama</string>
<string name="Snabble.Keyguard.requireScreenLock">Aby si mohol/mohla priradiť tento spôsob platby, musíš chrániť svoj smartfón uzamknutím displeja.</string>
<string name="Snabble.Keyguard.title">Prosím, odomknite svoj smartfón</string>
Expand Down
1 change: 0 additions & 1 deletion ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<string name="Snabble.Hints.closedBags">Well done! Please make things easy for the cashier and don\'t store your products in closed bags. Thank you!</string>
<string name="Snabble.Hints.continueScanning">Continue scanning</string>
<string name="Snabble.Hints.title">Info from %s</string>
<string name="Snabble.InvalidDepositVoucher.errorMsg">Deposit return vouchers can be redeemed only once.</string>
<string name="Snabble.Keyguard.message">That\'s how we make sure that only you have access to this payment method</string>
<string name="Snabble.Keyguard.requireScreenLock">You need to secure your smartphone with a screen lock to add this payment method.</string>
<string name="Snabble.Keyguard.title">Please unlock your device</string>
Expand Down
Loading