Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file.
### Removed
### Fixed

## [0.82.2]
### Fixed
* Unlock frozen camera after scan
* Wrong applied price modifiers
*
## [0.82.1]
### Changed
* Dependency updates
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ data class LineItem(
data class PriceModifier(
val name: String? = null,
val price: Int = 0,
val action: String? = null
)

data class ExitToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,14 @@ class ShoppingCart(
}
}

fun notifyOnlinePriceUpdate(list: ShoppingCart) {
Dispatch.mainThread {
listeners?.forEach { listener ->
listener.onOnlinePricesUpdated(list)
}
}
}

private fun notifyTaxationChanged(list: ShoppingCart, taxation: Taxation) {
Dispatch.mainThread {
listeners?.forEach { listener ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ internal class ShoppingCartUpdater(
invalidItemIds = null
checkLimits()
notifyPriceUpdate(this)
notifyOnlinePriceUpdate(this)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface DefaultShoppingCartListener : ShoppingCartListener {
override fun onPricesUpdated(cart: ShoppingCart) {
}

override fun onOnlinePricesUpdated(cart: ShoppingCart) {}

override fun onCheckoutLimitReached(cart: ShoppingCart) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ShoppingCartListener {
fun onItemRemoved(cart: ShoppingCart, item: ShoppingCart.Item, pos: Int)
fun onProductsUpdated(cart: ShoppingCart)
fun onPricesUpdated(cart: ShoppingCart)
fun onOnlinePricesUpdated(cart: ShoppingCart)
fun onCheckoutLimitReached(cart: ShoppingCart)
fun onOnlinePaymentLimitReached(cart: ShoppingCart)
fun onTaxationChanged(cart: ShoppingCart, taxation: Taxation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ abstract class SimpleShoppingCartListener : ShoppingCartListener {

override fun onPricesUpdated(cart: ShoppingCart) = onChanged(cart)

override fun onOnlinePricesUpdated(cart: ShoppingCart) = onChanged(cart)

override fun onTaxationChanged(cart: ShoppingCart, taxation: Taxation) = onChanged(cart)

override fun onCheckoutLimitReached(cart: ShoppingCart) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ internal data class ProductItem(
.sumOf { it.price * quantity }
.let(::abs)
}
return totalPrice + depositPrice + sumOfModifierPriceDiscounts
return if (item.lineItem?.priceModifiers?.firstOrNull()?.action == "replace") item.lineItem?.price
?: 0 else totalPrice + depositPrice + sumOfModifierPriceDiscounts
}

fun getPriceWithDiscountsApplied(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class ScannerBottomSheetView @JvmOverloads constructor(

override fun onProductsUpdated(cart: ShoppingCart) {}
override fun onPricesUpdated(cart: ShoppingCart) = checkSaleStop()
override fun onOnlinePricesUpdated(cart: ShoppingCart) {}
override fun onCheckoutLimitReached(cart: ShoppingCart) {}
override fun onOnlinePaymentLimitReached(cart: ShoppingCart) {}
override fun onTaxationChanged(cart: ShoppingCart, taxation: Taxation) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.os.Vibrator;
import android.text.InputType;
Expand Down Expand Up @@ -602,6 +604,13 @@ public void onQuantityChanged(@NonNull ShoppingCart cart, ShoppingCart.Item item
showScanMessage(item.getProduct(), false);
}

@Override
public void onOnlinePricesUpdated(@NonNull ShoppingCart cart) {
Handler infoHandler = new Handler(Looper.getMainLooper());
infoHandler.postDelayed(() -> resumeBarcodeScanner(), 500);
}


@Override
public void onChanged(@NonNull ShoppingCart cart) {
updateCartButton();
Expand Down