feat qr #refs 7520

This commit is contained in:
Sergio De la torre 2024-06-18 12:31:40 +02:00
parent 3bed3d96b4
commit 284d4509b1
1 changed files with 22 additions and 7 deletions

View File

@ -13,7 +13,7 @@ data class ItemScanned(var scanned: JSONObject) {
var user: Int = scanned.get("user").toString().toInt()
@RequiresApi(Build.VERSION_CODES.O)
var created = DateTimeFormatter.ISO_INSTANT.parse(scanned.get("created").toString())
var created = DateTimeFormatter.ISO_INSTANT.parse(scanned.get("created").toString())
}
@ -27,7 +27,8 @@ fun itemScanIsQr(value: String): Boolean {
false
}
}
fun itemScanValue(value: String, table: String, field: String): Any {
fun itemScanValue(value: String, table: Array<String>, field: String): Any {
val item: ItemScanned
return try {
@ -37,14 +38,28 @@ fun itemScanValue(value: String, table: String, field: String): Any {
return value
}
if (item.company == "vnl" && item.table == table) {
if (item.company == "vnl" && item.table in table) {
when (item.table) {
when (field) {
"id" -> return item.id
"more" -> return item.more
"ticket" -> {
return item.id
}
"saleGroup" -> {
return item.id
}
"buy" -> {
when (field) {
"id" -> return item.id
"more" -> return item.more
}
}
"expeditionPallet" -> {
return item.id
}
}
}
throw Exception("QR no válido")