aboutsummaryrefslogtreecommitdiff
path: root/merchant-terminal/src
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-09-03 14:35:49 -0300
committerTorsten Grote <t@grobox.de>2020-09-03 14:39:30 -0300
commite92fb0d6d4f20c0109638a695f30bd8737686d7b (patch)
treefdf59619d448a03cca786880185ecacc8832d326 /merchant-terminal/src
parent4572a3d5fc5ae5f3bbeaa8836fb919dcec0483e0 (diff)
downloadtaler-android-e92fb0d6d4f20c0109638a695f30bd8737686d7b.tar.gz
taler-android-e92fb0d6d4f20c0109638a695f30bd8737686d7b.tar.bz2
taler-android-e92fb0d6d4f20c0109638a695f30bd8737686d7b.zip
Remove instance parameter from merchant config
and reset order state when moving to new config
Diffstat (limited to 'merchant-terminal/src')
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/config/PosConfig.kt3
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt12
2 files changed, 7 insertions, 8 deletions
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/config/PosConfig.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/config/PosConfig.kt
index 7def7cc..971f92c 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/config/PosConfig.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/config/PosConfig.kt
@@ -23,6 +23,7 @@ import net.taler.common.ContractProduct
import net.taler.common.Product
import net.taler.common.TalerUtils
import net.taler.lib.common.Amount
+import net.taler.merchantlib.MerchantConfig
import java.util.UUID
data class Config(
@@ -37,7 +38,7 @@ data class Config(
@Serializable
data class PosConfig(
@SerialName("config")
- val merchantConfig: net.taler.merchantlib.MerchantConfig,
+ val merchantConfig: MerchantConfig,
val categories: List<Category>,
val products: List<ConfigProduct>
)
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt
index 56cdc8a..a89a85d 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt
@@ -88,12 +88,10 @@ class OrderManager(private val context: Context) : ConfigurationReceiver {
this.currency = currency
mCategories.postValue(posConfig.categories)
mProducts.postValue(productsByCategory[posConfig.categories[0]])
- // Initialize first empty order, note this won't work when updating config mid-flight
- if (orders.isEmpty()) {
- val id = orderCounter++
- orders[id] = MutableLiveOrder(id, currency, productsByCategory)
- mCurrentOrderId.postValue(id)
- }
+ orders.clear()
+ orderCounter = 0
+ orders[0] = MutableLiveOrder(0, currency, productsByCategory)
+ mCurrentOrderId.postValue(0)
null // success, no error string
} else context.getString(R.string.config_error_product_zero)
}
@@ -116,7 +114,7 @@ class OrderManager(private val context: Context) : ConfigurationReceiver {
if (orderId == currentId) foundCurrentOrder = true
}
if (nextId == null) {
- nextId = orderCounter++
+ nextId = ++orderCounter
orders[nextId] = MutableLiveOrder(nextId, currency, productsByCategory)
}
val currentOrder = order(currentId)