From e92fb0d6d4f20c0109638a695f30bd8737686d7b Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 3 Sep 2020 14:35:49 -0300 Subject: Remove instance parameter from merchant config and reset order state when moving to new config --- .../main/java/net/taler/merchantpos/order/OrderManager.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'merchant-terminal/src/main/java/net/taler/merchantpos/order/OrderManager.kt') 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) -- cgit v1.2.3