aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--merchant-lib/src/main/java/net/taler/merchantlib/Config.kt3
-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
3 files changed, 7 insertions, 11 deletions
diff --git a/merchant-lib/src/main/java/net/taler/merchantlib/Config.kt b/merchant-lib/src/main/java/net/taler/merchantlib/Config.kt
index eb09485..572ab3d 100644
--- a/merchant-lib/src/main/java/net/taler/merchantlib/Config.kt
+++ b/merchant-lib/src/main/java/net/taler/merchantlib/Config.kt
@@ -38,15 +38,12 @@ data class ConfigResponse(
data class MerchantConfig(
@SerialName("base_url")
val baseUrl: String,
- // TODO remove instance when it is part of baseURL
- val instance: String? = null,
@SerialName("api_key")
val apiKey: String
) {
fun urlFor(endpoint: String): String {
val sb = StringBuilder(baseUrl)
if (sb.last() != '/') sb.append('/')
- instance?.let { sb.append("instances/$it/") }
sb.append(endpoint)
return sb.toString()
}
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)