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() var user: Int = scanned.get("user").toString().toInt()
@RequiresApi(Build.VERSION_CODES.O) @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 false
} }
} }
fun itemScanValue(value: String, table: String, field: String): Any {
fun itemScanValue(value: String, table: Array<String>, field: String): Any {
val item: ItemScanned val item: ItemScanned
return try { return try {
@ -37,14 +38,28 @@ fun itemScanValue(value: String, table: String, field: String): Any {
return value return value
} }
if (item.company == "vnl" && item.table == table) { if (item.company == "vnl" && item.table in table) {
when (item.table) {
when (field) { "ticket" -> {
"id" -> return item.id return item.id
"more" -> return item.more }
"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") throw Exception("QR no válido")