fix(receipt-import): correct regex for single pack extraction to handle unit formatting
This commit is contained in:
@@ -81,7 +81,7 @@ function inferPackageDebugFromRawName(rawName: string): {
|
||||
}
|
||||
|
||||
// e.g. "5dl", "1,5l"
|
||||
const singlePack = /(\d+(?:[\.,]\d+)?)\s*(ml|cl|dl|l|g|kg)\b/i.exec(normalized);
|
||||
const singlePack = /(\d+(?:[\.,]\d+)?)\s*(ml|cl|dl|l|g|kg)\b/i.exec(normalized.replace(/([\d.,]+)(ml|cl|dl|l|g|kg)\b/i, '$1 $2'));
|
||||
if (singlePack) {
|
||||
const qty = Number.parseFloat(singlePack[1].replace(',', '.'));
|
||||
const unit = singlePack[2].toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user