This commit is contained in:
leca 2024-10-18 15:08:26 +03:00
parent c112eec868
commit e9ef4c44f9
2 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package org.foxarmy.barcodescannerforemployees
import android.util.Log
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
class Parser constructor() {
@ -34,7 +35,19 @@ class Parser constructor() {
Regex("[0-9]+,?[0-9*]\\s*((шт)|(Шт))")
)
)
var unitNumber = -1
val strippedUnit = unit.lowercase().replace(Regex("\\d"), "").strip()
unitNumber = when (strippedUnit) {
"кг" -> { 0 }
"г" -> { 1 }
"л" -> { 2 }
"мл" -> { 3 }
"шт" -> { 4 }
return AbstractProduct(0, "", name, netWeight, "", 0, unit)
else -> { -1 }
}
Log.d("QWERTYUIOP", "Unit: ${strippedUnit}, number: ${unitNumber}")
return AbstractProduct(0, "", name, netWeight, "", 0, unitNumber)
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="gram">g</string>
<string name="kilogram">kg</string>
<string name="gram">g</string>
<string name="liter">l</string>
<string name="milliliter">ml</string>
<string name="pieces">pc</string>